---
title: "Market basket analysis: support, confidence, and lift"
description: "Support, confidence, and lift computed in SQL on 4,451 orders from the public GA4 sample, with a reading grid that turns a product pair into a decision."
canonical: https://www.rtbanalytics.fr/en/blog/journeys-baskets-retention/market-basket-analysis-support-confidence-lift
date: 2026-11-25T11:30:00+01:00
author: "Boris Parov"
lang: en
---

# Market basket analysis: support, confidence, and lift explained with real orders

Market basket analysis measures which products are bought together with three numbers: support, confidence, and lift. Each answers a different question, and a high lift on a tiny support is not a decision. This article computes all three in SQL on 4,451 orders from Google's public sample. It extends our guide to the e-commerce analyses GA4 doesn't show.

**Key takeaways**

- Support, confidence, and lift answer three questions about a product pair: how common, how predictive, and how far beyond chance.
- On 4,451 orders of the public sample, two Google pen colors share 22 orders: a support of 0.49% and a lift of 78.8.
- Confidence has a direction: on the public sample, 83.3% of orders with the Kirkland campus mug contain the Seattle mug, against 25.9% the other way.
- Raising the floor from 1 to 10 shared orders cuts the candidate pairs from 16,195 to 105 on the sample.
- The most frequent pair on the sample, two light pen colors, sits in 0.88% of orders with a lift of 32.2.

## Three questions, three measures: what does market basket analysis compute?

Market basket analysis turns one count, the orders that contain two given products, into three measures. Support asks whether the pair is common enough to matter. Confidence asks how often buyers of A also take B. Lift asks whether the pair occurs more often than chance would produce.

All three are computed on orders, not on sessions or users. In the GA4 BigQuery export, an order is a `purchase` event. Its `ecommerce.transaction_id` identifies it, and its `items` array lists its products. An order with three products yields three pairs: A with B, A with C, and B with C.

| Measure           | Question it answers                      | Formula                                           | Pen pair on the sample |
| ----------------- | ---------------------------------------- | ------------------------------------------------- | ---------------------- |
| Support           | How common is the pair?                  | Orders with A and B ÷ all orders                  | 22 ÷ 4,451 = 0.49%     |
| Confidence A to B | When A is in the basket, how often is B? | Orders with A and B ÷ orders with A               | 22 ÷ 46 = 47.8%        |
| Lift              | How far beyond chance is the pair?       | Support ÷ (share of orders with A × share with B) | 78.8                   |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

The three measures never rank pairs the same way. A rare pair can top the lift list and barely register in support. Two bestsellers can share many orders and still have a lift close to 1. Each measure gets its own section here, then the last one reads them together.

## Support: is the pair frequent enough to count?

Support is the share of all orders that contain both products. It decides whether a pair is worth reading at all. A pair found in a handful of baskets may be a coincidence. A pair found in 1% of orders is a pattern a bundle can act on.

**Support** is the share of all orders that contain a given pair of products; it measures how common the pair is, whatever the popularity of each product on its own.

On the public sample, support is small for every pair. The most frequent pair, two light pen colors, appears in 39 of 4,451 orders, or 0.88%. That is normal for a catalog of hundreds of products. Hence the floor: a minimum of shared orders under which a pair is ignored. This query counts the pairs that survive each floor, on the same orders.

```sql
WITH orders AS (
  SELECT DISTINCT ecommerce.transaction_id, item.item_name
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`, UNNEST(items) AS item
  WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
    AND event_name = 'purchase' AND item.item_name IS NOT NULL
    AND ecommerce.transaction_id IS NOT NULL AND ecommerce.transaction_id != '(not set)'
),
totals AS (SELECT COUNT(DISTINCT transaction_id) AS n_orders FROM orders),
item_counts AS (SELECT item_name, COUNT(DISTINCT transaction_id) AS n FROM orders GROUP BY item_name),
pairs AS (
  SELECT a.item_name AS item_a, b.item_name AS item_b, COUNT(DISTINCT a.transaction_id) AS n_ab
  FROM orders a JOIN orders b ON a.transaction_id = b.transaction_id AND a.item_name < b.item_name
  GROUP BY item_a, item_b
),
scored AS (
  SELECT p.n_ab, p.n_ab * t.n_orders / (ca.n * cb.n) AS lift
  FROM pairs p
  JOIN item_counts ca ON ca.item_name = p.item_a
  JOIN item_counts cb ON cb.item_name = p.item_b
  CROSS JOIN totals t
)
SELECT min_orders,
  COUNTIF(n_ab >= min_orders) AS pairs_kept,
  COUNTIF(n_ab >= min_orders AND lift >= 10) AS pairs_with_lift_10_plus,
  ROUND(MAX(IF(n_ab >= min_orders, lift, NULL)), 1) AS max_lift
FROM scored, UNNEST([1, 2, 5, 10, 20]) AS min_orders
GROUP BY min_orders
ORDER BY min_orders
```

| Minimum shared orders | Pairs kept | Pairs with a lift of 10 or more | Highest lift |
| --------------------- | ---------- | ------------------------------- | ------------ |
| 1                     | 16,195     | 3,496                           | 635.9        |
| 2                     | 5,214      | 1,205                           | 635.9        |
| 5                     | 643        | 201                             | 353.3        |
| 10                    | 105        | 56                              | 78.8         |
| 20                    | 11         | 9                               | 78.8         |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data).

The floor changes the result more than any formula. With no floor, 16,195 pairs qualify and the top lift reaches 635.9, from pairs bought together once. A floor of 10 shared orders keeps 105 pairs and caps the top lift at 78.8. Set the floor as a count of orders, because a count says how many baskets back each pair.

## Confidence: if a customer buys A, how often do they buy B?

Confidence from A to B is the share of orders containing A that also contain B. It reads as a rule: when A is in the basket, B follows in a known share. A "frequently bought together" block relies on this measure, even when nobody names it.

**Confidence** is the share of orders containing product A that also contain product B; it is directional, so the confidence from A to B and the confidence from B to A usually differ.

Direction matters because two products rarely share the same audience. On the sample, 83.3% of orders with the Google Kirkland Campus Mug contain the Google Seattle Campus Mug. Only 25.9% of Seattle mug orders contain the Kirkland mug. The Seattle mug sits in 58 orders, the Kirkland mug in 18. Suggesting the Seattle mug on the Kirkland page has the data behind it. The reverse suggestion is a weak bet.

Confidence also has a blind spot: a bestseller inflates it. If B appears in 30% of all orders, almost any A shows a confidence near 30% towards B. That figure describes B's popularity, not a link with A. Lift exists to correct that bias.

## Lift: is the pair bought together more than chance?

Lift divides the observed support of a pair by the support expected under independent buying. A lift of 1 means no link. A lift of 3 means the pair appears three times as often as chance predicts. A lift under 1 means the products avoid each other.

**Lift** is the ratio between the observed share of orders containing two products and the share expected if the two were bought independently; a lift of 1 means no link, and a lift above 1 means the products attract each other.

The pen pair shows the arithmetic. Google Pen Bright Blue sits in 46 orders and Google Pen Grass Green in 27, out of 4,451. Bought independently, they would share about 0.28 orders. They share 22, hence a lift of 78.8.

Lift is symmetric: it has the same value from A to B and from B to A. That makes it a good sorting key for a list of affinities. It is a poor decision key on its own. Lift grows when both products are rare, because the expected count shrinks towards zero. With no floor, a lift of 635.9 tops the sample's list, from a single shared order. A lift is a hypothesis to check against support, never a verdict.

## SQL on the public sample: the top ten pairs

The query computes the three measures for every pair in one pass, then keeps ten pairs. Five are the strongest by lift, five the most frequent by shared orders. It reads the `purchase` events of the public sample, from November 2020 to January 2021. The function `UNNEST(items)` gives one row per product and order. A self-join on `ecommerce.transaction_id` then gives the pairs. The condition `a.item_name < b.item_name` keeps each pair once. Both are detailed in [The GA4 e-commerce events that build the funnel, from view_item to purchase](https://www.rtbanalytics.fr/en/blog/ecommerce-funnel-checkout/ga4-ecommerce-events-funnel).

```sql
WITH orders AS (
  SELECT DISTINCT ecommerce.transaction_id, item.item_name
  FROM `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`, UNNEST(items) AS item
  WHERE _TABLE_SUFFIX BETWEEN '20201101' AND '20210131'
    AND event_name = 'purchase' AND item.item_name IS NOT NULL
    AND ecommerce.transaction_id IS NOT NULL AND ecommerce.transaction_id != '(not set)'
),
totals AS (SELECT COUNT(DISTINCT transaction_id) AS n_orders FROM orders),
item_counts AS (SELECT item_name, COUNT(DISTINCT transaction_id) AS n FROM orders GROUP BY item_name),
pairs AS (
  SELECT a.item_name AS item_a, b.item_name AS item_b, COUNT(DISTINCT a.transaction_id) AS n_ab
  FROM orders a JOIN orders b ON a.transaction_id = b.transaction_id AND a.item_name < b.item_name
  GROUP BY item_a, item_b
)
SELECT p.item_a, p.item_b, p.n_ab AS orders_together, ca.n AS orders_a, cb.n AS orders_b,
  ROUND(100 * p.n_ab / t.n_orders, 2) AS support_pct,
  ROUND(100 * p.n_ab / ca.n, 1) AS confidence_a_to_b_pct,
  ROUND(100 * p.n_ab / cb.n, 1) AS confidence_b_to_a_pct,
  ROUND(p.n_ab * t.n_orders / (ca.n * cb.n), 1) AS lift,
  ROW_NUMBER() OVER (ORDER BY p.n_ab * t.n_orders / (ca.n * cb.n) DESC) AS rank_by_lift,
  ROW_NUMBER() OVER (ORDER BY p.n_ab DESC, p.item_a) AS rank_by_orders
FROM pairs p
JOIN item_counts ca ON ca.item_name = p.item_a
JOIN item_counts cb ON cb.item_name = p.item_b
CROSS JOIN totals t
WHERE p.n_ab >= 10
QUALIFY rank_by_lift <= 5 OR rank_by_orders <= 5
ORDER BY rank_by_lift
```

| Product A                  | Product B                 | Orders together | Orders with A / with B | Support | Confidence A to B | Confidence B to A | Lift |
| -------------------------- | ------------------------- | --------------- | ---------------------- | ------- | ----------------- | ----------------- | ---- |
| Google Pen Bright Blue     | Google Pen Grass Green    | 22              | 46 / 27                | 0.49%   | 47.8%             | 81.5%             | 78.8 |
| Google Pen Grass Green     | Google Pen Red            | 12              | 27 / 27                | 0.27%   | 44.4%             | 44.4%             | 73.3 |
| Google Pen Lilac           | Google Pen Neon Coral     | 15              | 31 / 30                | 0.34%   | 48.4%             | 50.0%             | 71.8 |
| Google Pen Grass Green     | Google Pen Neon Coral     | 12              | 27 / 30                | 0.27%   | 44.4%             | 40.0%             | 65.9 |
| Google Kirkland Campus Mug | Google Seattle Campus Mug | 15              | 18 / 58                | 0.34%   | 83.3%             | 25.9%             | 64.0 |

Ranked by shared orders, the same result returns five other pairs:

| Product A                             | Product B                      | Orders together | Orders with A / with B | Support | Confidence A to B | Confidence B to A | Lift |
| ------------------------------------- | ------------------------------ | --------------- | ---------------------- | ------- | ----------------- | ----------------- | ---- |
| Google Light Pen Blue                 | Google Light Pen Red           | 39              | 83 / 65                | 0.88%   | 47.0%             | 60.0%             | 32.2 |
| Google Light Pen Green                | Google Light Pen Red           | 38              | 56 / 65                | 0.85%   | 67.9%             | 58.5%             | 46.5 |
| Google Light Pen Blue                 | Google Light Pen Green         | 35              | 83 / 56                | 0.79%   | 42.2%             | 62.5%             | 33.5 |
| Android Large Removable Sticker Sheet | Android SM S/F18 Sticker Sheet | 27              | 47 / 97                | 0.61%   | 57.4%             | 27.8%             | 26.4 |
| Google Crew Combed Cotton Sock        | Google Crew Socks              | 26              | 80 / 127               | 0.58%   | 32.5%             | 20.5%             | 11.4 |

Computed on 2026-10-15 on the public sample `bigquery-public-data.ga4_obfuscated_sample_ecommerce` (Google Merchandise Store, 2020-11-01 to 2021-01-31, obfuscated data), 4,451 orders with a transaction id, pairs with at least 10 shared orders.

The two lists share no pair. The lift leaders share 12 to 22 orders; the frequency leaders share 26 to 39. The top pair by lift ranks only ninth by shared orders. All ten lifts exceed 11, so every pair is a real affinity on this obfuscated, three-month sample.

## Reading a pair: bundle, placement, or substitute?

A product pair becomes a decision only when support, confidence, and lift are read together. Each profile of the three measures calls for a different action. The grid maps five common profiles to an action, with an example from the sample where one exists.

| Profile                          | Reading                             | Action                                    | Example on the sample                              |
| -------------------------------- | ----------------------------------- | ----------------------------------------- | -------------------------------------------------- |
| High support, lift well beyond 1 | A mainstream affinity               | Bundle, or side-by-side placement         | Light Pen Blue and Red: 0.88%, lift 32.2           |
| High lift, tiny support          | A niche affinity, still fragile     | Small test only; no navigation change     | Pen Bright Blue and Grass Green: 0.49%, lift 78.8  |
| High confidence in one direction | A one-way rule                      | Cross-sell B on A's page, not the reverse | Kirkland to Seattle mug: 83.3%, against 25.9% back |
| High support, lift close to 1    | Two bestsellers that meet by volume | No pairing action                         | None among the ten pairs                           |
| Lift under 1, same category      | Products that replace each other    | Show as alternatives, not add-ons         | Not computed here                                  |

The light pens fit the first profile. Their link holds across 39 orders, so a multi-color pack is a sound candidate. The bright pen colors fit the second: 22 orders could come from one promotion or one corporate buyer. The mugs fit the third, and the direction decides which page carries the suggestion.

Every action stays a test, because lift measures association, not cause. Placement also depends on what visitors ask for. Internal search shows that demand side, as covered in Site search: the terms that lead to a purchase. Once dozens of pairs pass the floor, a list gets hard to read. Drawing them as a graph is the subject of Products bought together: from basket pairs to the affinity network.

> **In Lightstack · Available**
>
> Lightstack, by RTB Strategic Analytics (Montpellier, France), recomputes consultancy-grade GA4 analyses every day from the raw BigQuery export and delivers them in Power BI. Its Market Basket and Product Affinity Network pages show product pairs with support, confidence, and lift, plus an affinity network, recomputed every day. See [Market basket in the analyses catalog](https://www.rtbanalytics.fr/en/analyses#catalog).

## FAQ

### What is a good lift value in market basket analysis?

No lift value is good in itself. A lift greater than 1 signals a positive association, and a lift under 1 a negative one. A useful pair combines a clear lift with enough shared orders. On the public sample, the ten pairs shown range from a lift of 11.4 to 78.8.

### How many orders do you need for a market basket analysis?

You need enough orders for pairs to reach your floor of shared orders. On the public sample, 4,451 orders over three months give 105 pairs with at least 10 shared orders. A smaller store can widen the date window. It can also pair product categories instead of products, which multiplies the shared orders per pair.

### Can the GA4 interface show products bought together?

No standard GA4 report counts two products in the same order. The item reports count each product on its own, and explorations do not build pairs. The BigQuery export keeps every `purchase` event with its `items` array. A self-join on the transaction id then builds the pairs in SQL.

### Should the analysis group products by item name or item ID?

Item IDs are the steadier key. A product renamed during the period splits into two names and halves its pair counts. The query here groups by `item_name` because names are readable on the sample. On your own export, group by `item_id` and attach the current name at the end.

The journey and retention methods that complete this one are gathered in Journeys, baskets, and repeat buyers: the e-commerce analyses GA4 doesn't show. To receive the next method as soon as it ships: [Get new analyses as they ship](https://www.rtbanalytics.fr/en/blog/journeys-baskets-retention/market-basket-analysis-support-confidence-lift#footer-newsletter-email).

## Sources

- [BigQuery export schema for Google Analytics 4](https://support.google.com/analytics/answer/7029846) - Google, consulted 2026-10-15
- [Measure ecommerce: the purchase event and its items](https://developers.google.com/analytics/devguides/collection/ga4/ecommerce) - Google, consulted 2026-10-15
- [Work with arrays in BigQuery, including UNNEST](https://docs.cloud.google.com/bigquery/docs/arrays) - Google Cloud, consulted 2026-10-15
- [Mining association rules between sets of items in large databases](https://doi.org/10.1145/170035.170072) - Agrawal, Imieliński, and Swami, ACM SIGMOD, 1993, consulted 2026-10-15
