Two products appear together in many orders. That is a useful merchandising clue, but it does not establish that recommending one caused the other to sell. A popular accessory may accompany almost everything. A compulsory kit may generate an impressive relationship that tells you nothing about voluntary shopper preference.
EcomToolkit recommends treating market basket analysis as a way to generate specific hypotheses. Start with transparent transaction counts, examine why the relationship exists, and test a commercially sensible intervention. This guide uses hypothetical orders throughout. It provides no claimed market benchmark, customer result, or guaranteed revenue improvement.
Table of Contents
- Define the basket before counting products
- Calculate support confidence and lift
- Reject impressive but unhelpful patterns
- Build a shortlist a merchandiser can challenge
- Validate on a later period
- Keep the pipeline reproducible
- EcomToolkit point of view
Define the basket before counting products
For a first analysis, define a basket as one eligible completed order containing distinct product identities. Quantity is a separate measure: three units of the same product still count as one occurrence of that product in the basket. An analysis of unit quantities answers a different question from an analysis of product co-occurrence.
Choose whether the identity is a variant, parent product, or product family. Combining red and blue variants may reveal a useful relationship between a lamp and a bulb. Combining all home accessories into one family may erase that relationship. Write down the mapping version so that a later catalog restructure does not silently change historical results.
Exclude test and cancelled orders under a documented rule. Decide how to handle refunds, exchanges, subscriptions, free gifts, and bundled components. You can analyze several views, but label them. A purchased-basket view and a retained-products view should not share an ambiguous heading such as customer preference.

Calculate support confidence and lift
Shopify’s market basket analysis introduction describes support, confidence, and lift as measures used to inspect product relationships. The calculations below apply those concepts to a deliberately small example. Association measures describe the observed baskets; none is a causal estimate of a recommendation’s effect.
Suppose there are 1,000 eligible orders. Product A appears in 200, product B appears in 100, and both appear in 40. Pair support is 40 divided by 1,000, or 4%. Confidence for the rule A to B is 40 divided by 200, or 20%. B’s overall frequency is 10%, so the lift is 20% divided by 10%, or 2.
| Quantity in the example | Calculation | Result |
|---|---|---|
| Support of A | 200 / 1,000 | 20% |
| Support of B | 100 / 1,000 | 10% |
| Pair support | 40 / 1,000 | 4% |
| Confidence A to B | 40 / 200 | 20% |
| Confidence B to A | 40 / 100 | 40% |
| Lift of the pair | 0.04 / (0.20 × 0.10) | 2.0 |
Confidence is directional: the share of A baskets containing B differs from the share of B baskets containing A. Pair lift is symmetric under these definitions. A team choosing a recommendation placement needs the directional measure as well as the pair relationship, because the available audience depends on which product anchors the placement.
The expected pair count under independence is 1,000 multiplied by 0.20 multiplied by 0.10, or 20. The observed count is 40. That difference describes association in these transactions. It is not evidence that a new widget would create 20 additional orders, because the baskets existed before the proposed intervention.
Reject impressive but unhelpful patterns
A rare pair can have a very high lift. If two products each occur in only two orders and both orders contain both products, the association looks dramatic. It may reflect one customer buying twice, a staff test, or a temporary kit. Review absolute counts before making a merchandising commitment.
A high-confidence relationship can also be ordinary. If 80% of all orders contain a promotional gift, finding the gift in 80% of A orders gives lift of one. The recommendation would be pointing at a product whose prevalence already explains the pattern. Confidence without the background frequency can make this look more special than it is.
Check operational constraints next. A camera and its required power adapter may be linked because the adapter is automatically added. Two products may appear together only during one discounted bundle campaign. Mark those mechanisms explicitly. An automated merchandising system should not learn compulsory relationships and present them as independent preference discoveries.
Compare periods with similar product availability. A pair cannot co-occur while one item is unavailable. If availability differs sharply, inspect an eligible-period view and report how much data it excludes. The availability-adjusted conversion guide explains the broader problem of interpreting shopper behavior when products cannot be purchased.
Build a shortlist a merchandiser can challenge
Rank candidates using both evidence and actionability. Include order counts, unique customer counts where available, directional confidence, lift, availability, and contribution implications. A shortlist should tell a merchandiser what to inspect, not automatically authorize a discount across the catalog.
Use a simple review sheet with an explicit reject reason. This preserves learning when a mathematically strong pair turns out to have no useful placement or unacceptable economics. It also prevents the same irrelevant pair from returning at the next monthly review.
| Candidate condition | Follow-up investigation | Possible merchandising action |
|---|---|---|
| Adequate count and clear compatibility | Confirm variants work together | Contextual accessory placement |
| High lift but very few customers | Inspect repeat buyers and campaigns | Collect more evidence |
| High confidence and ordinary lift | Compare background popularity | Avoid special claims |
| Strong pair with frequent returns | Review fit and product expectations | Improve compatibility copy first |
| Association created by a bundle | Separate voluntary purchases | Evaluate bundle economics separately |
The commercial calculation should use expected contribution after product cost, discounts, and relevant variable expenses. A cross-sell that merely moves an already-planned purchase into a discounted bundle can increase attach rate while reducing contribution. Pair counts do not resolve that tradeoff.

Validate on a later period
Discover patterns in one period and check whether they persist in a later period that was not used to select them. Keep the product mapping and eligibility rules stable. Review the impact of seasonality, campaign changes, and assortment changes before deciding that a relationship has strengthened or disappeared.
Searching thousands of pairs makes it easy to discover extreme values by chance. A minimum count is a practical screening rule, not a statistical significance guarantee. Avoid presenting every passing pair as a validated customer insight. Larger decision stakes may justify a formal analysis designed for multiple comparisons and customer dependence.
Then test a specific intervention, such as placing a compatible accessory below the selected variant. Keep the placement stable and measure outcomes for the eligible randomized audience where experimentation is feasible. Include purchase conversion, contribution per eligible visitor, returns, and interface performance. Recommendation clicks alone cannot establish commercial success.
Keep the pipeline reproducible
Store the input period, timezone, order status rule, product mapping, and extraction timestamp with each result. Retain both numerator counts and denominators. A later analyst should be able to reproduce the pair table without guessing whether bundles were expanded into components or counted as one product.
Validate a small hand-counted set before running the full archive. Include duplicate lines for the same product, two orders from one customer, a refunded item, and an automatically added gift. Confirm that distinct-product counting behaves as intended and that exclusion rules do not remove entire legitimate baskets unexpectedly.
Publish a shortlist with owners and next actions rather than a large unexplained matrix. The bundle and cross-sell analytics guide can help connect a selected intervention to the operating scorecard. Revisit the shortlist when pricing or compatibility changes, not just when the reporting calendar turns.
EcomToolkit point of view
A good basket analysis makes a merchandiser more precise about what to test. It distinguishes popularity from association, association from mechanism, and mechanism from profitable incremental demand. Keep the counts visible and the claims modest. If your recommendation plan rests on unexplained pair scores, request an EcomToolkit audit to review the data definition and the commercial experiment before expanding the placement.