Two products show up together in 8 percent of all orders. On their own, each one shows up in roughly 20 percent of orders. If the two were bought completely independently of each other, you would expect to see both in the same order about 4 percent of the time (20 percent times 20 percent). They are actually showing up together twice as often as chance alone would predict, a lift score of 2.0, and that single number is most of what market basket analysis is actually computing.
That part is arithmetic. A spreadsheet, a BigQuery query, or a Python notebook can produce a lift score in an afternoon once you hand it clean data. The part every tutorial underplays is getting to "clean data" in the first place, because an ecommerce order table is nowhere near as tidy as the retail transaction logs the math was originally built for.
- Market basket analysis ecommerce brands can act on scores product pairs on support, confidence, and lift to find what customers actually buy together, not what a category page assumes they would.
- The formula has not changed in decades. What breaks the result is bundles, subscriptions, and returns sitting uncorrected in the order data before anything gets counted.
- GA4's items array and Shopify's line items are the two realistic sources for basket-level data; most guides assume this table already exists and skip how to build it.
- A lift above roughly 2.0 is the common threshold for a pairing worth testing as a cross-sell, upsell, or bundle.
What support, confidence, and lift are actually measuring
Market basket analysis, sometimes called association rule learning, scores every pair of products on three numbers. Google Cloud's BigQuery documentation names the metrics directly: leverage, support, confidence, and lift are what the technique uses to surface a genuine purchase pattern instead of a coincidence.
Support is simply how often a pairing shows up, as a share of every order in the dataset. Confidence narrows that to a direction: given that a customer bought product A, what share of the time did they also buy product B. Lift is the one that actually tells you whether the pairing means anything, by comparing the observed co-purchase rate against what pure chance would produce if the two products had nothing to do with each other.
A lift of 1.0 means no relationship worth acting on. A lift of 2.0 or higher, the range most practitioners treat as a working threshold, means the pairing shows up roughly twice as often as random chance, which is usually enough signal to justify a cross-sell test. None of this requires a statistics background to apply. It requires a transaction table where each row is one order and each column is one product, which is exactly the thing most ecommerce stores do not already have sitting in a usable form.
Where the basket actually comes from
Most market basket analysis guides start with a dataset that is already basket-shaped, one row per transaction, one column per item, because they were written for a retail point-of-sale system where that table falls out of the register automatically. Ecommerce does not hand you that table. You have to build it from one of two places.
If you run GA4 with BigQuery Export linked, the basket lives inside the items array nested in every purchase event. Google's own ecommerce measurement guide documents that array as a list of every item included in the transaction, each with its own item_id, item_name, price, and quantity, all nested under the same transaction_id. Flattening that array, grouping by transaction_id, is the basket.
If you are working from Shopify directly, the same basket exists in the order's line items. The Admin API's LineItem object returns every product in an order with its own product ID and quantity, attached to the parent order. You do not need GA4 at all to build a basket table this way, and for stores where GA4 tracking has known gaps, the Shopify order export is usually the more trustworthy source anyway.
Either path gets you to the same destination: one table, one row per order, with the product IDs it contained. That table is the actual deliverable most market basket tutorials assume you already own. Building it is the first real task, not an afterthought before "the math."
Three things that fake a product affinity
Once the basket table exists, three ecommerce-specific problems produce lift scores that look like discoveries and are actually noise.
Subscription renewals inflate lift for the same reason. A subscription that ships the same two products every cycle generates a fresh "order" each renewal, and every one of those orders counts as a fresh data point toward that pair's support and confidence. The resulting lift score can look like your strongest cross-sell signal when it is really one subscription configuration repeating itself. Exclude recurring subscription orders from the basket table, or at minimum flag them, before trusting a top-pairs list.
Returns and refunds should be pulled out before counting, not after. An order where a customer bought two sizes of the same shirt and returned one is not a cross-sell insight, it is a sizing problem wearing a market-basket disguise. This is the same category of data hygiene issue that corrupts RFM segmentation when refunds are not netted out before scoring, and it shows up here for the same reason: the raw order export records what was ordered, not what was kept.
A fourth issue worth a mention, because it is easy to miss: if the basket table is built at the SKU or variant level rather than the parent product level, the same product sold in five sizes gets fragmented into five separate items that never show enough individual volume to register a pairing. Roll variants up to their parent product ID before building the basket, unless the specific size or color combination is itself the question you are trying to answer.
Reconciling the table before you trust a pairing
Every one of those hygiene problems assumes the basket table was built from accurate source data in the first place, which is not guaranteed. If your GA4 purchase events and your Shopify order count disagree even before you get to market basket analysis, the pairings you compute from either source inherit that disagreement. We have walked through diagnosing a GA4-to-Shopify revenue mismatch where duplicate order IDs across reporting sources inflated revenue by roughly 40 percent for one store; the same duplication would just as quietly double-count a product pairing's support if it reached the basket table unreconciled. A tracking audit is the step that catches this kind of duplication at the source, before it works its way into any downstream analysis, market basket pairings included.
From a lift score to a decision
A lift score by itself changes nothing. The decision that follows it is where the analysis earns its keep, and it splits into three reasonably distinct moves depending on the strength of the signal.
A pairing with a lift above 2.0 and healthy support, meaning it is not just two or three orders, is strong enough to test as a product page cross-sell module or a post-purchase upsell offer without much risk. A pairing with a high lift but thin support is worth watching for another sales cycle before committing a merchandising slot to it. A pairing with a lift near 1.0, however familiar the two products feel as a combination, is not a pattern your customers are actually creating, it is a category assumption dressed up as data.
Shopify has documented at least one case where this mechanism produced a concrete result: the merchant WHO IS ELIJAH built a Black Friday bundle from a discovered product pairing and grew average order value from $86 to $126. That is one documented outcome from one catalog, not a universal percentage, but it is a real example of a lift score turning into a priced decision rather than sitting in a spreadsheet.
Where this tends to stall for most ecommerce teams is not the decision step, it is everything upstream of it: building the basket table correctly, stripping bundles and subscriptions out of it, and reconciling it against whichever platform's order count you actually trust. That is the part worth getting help with if it is eating more analyst time than the resulting cross-sell tests are worth, which is exactly what a product analytics engagement is built to take off your plate, one clean customer and order table that market basket analysis, cohort retention, and RFM scoring can all read from without each one rebuilding it from scratch.
Get the table right once, and the lift score was always going to be the easy part.

