Quick answer
Product affinity analysis (market basket analysis) finds products bought together more often than chance. It scores each pair with support, confidence and lift; a pair shows real affinity only when lift is clearly above 1 and enough orders contain it.
Formula: support = orders with A and B ÷ all orders; confidence(A→B) = orders with A and B ÷ orders with A; lift = confidence(A→B) ÷ share of orders with B
What is product affinity analysis?
Product affinity analysis finds products that are bought together more often than chance would predict. It is also called market basket analysis or affinity analysis, and it works on order data: each order is a "basket" of items, and the analysis counts how often items appear in the same basket.
The method comes from association-rule mining. Agrawal, Imieliński and Swami introduced rules of the form "if a basket contains A, it also tends to contain B" and measured them with support and confidence in their 1993 SIGMOD paper (dblp record). Brin, Motwani and Silverstein later showed that support and confidence alone can rank misleading rules highly and proposed measuring correlation instead, with an "interest" ratio and the chi-squared test (dblp record). That ratio is what most tools now call lift.
The practical point of this page: a rule is only worth acting on when its lift is clearly above 1 and it rests on enough orders. High confidence on its own is not evidence of affinity.
Support, confidence and lift
For a rule A → B (customers who buy A also buy B), with N orders in total:
| Measure | Formula | Answers |
|---|---|---|
| Support of the pair | orders with A and B ÷ N | How common is the pair at all? |
| Confidence (A → B) | orders with A and B ÷ orders with A | Of baskets with A, what share also has B? |
| Lift (A → B) | confidence (A → B) ÷ (orders with B ÷ N) | How much more likely is B when A is in the basket, compared with any basket? |
Lift reads simply: 1.0 means A tells you nothing about B, above 1 means they go together, below 1 means they tend not to. Lift is symmetric (A → B and B → A have the same lift), while confidence is not.
Worked example: 1,000 orders
Sample data: an electronics store has 1,000 orders in a month. 200 contain a phone case, 150 contain a screen protector and 90 contain both.
| Step | Calculation | Result |
|---|---|---|
| Support (case and protector) | 90 ÷ 1,000 | 9.0% |
| Confidence (case → protector) | 90 ÷ 200 | 45% |
| Confidence (protector → case) | 90 ÷ 150 | 60% |
| Base rate of protector | 150 ÷ 1,000 | 15% |
| Lift | 0.45 ÷ 0.15 | 3.0 |
| Expected orders with both, if independent | 200 × 150 ÷ 1,000 | 30 |
The pair appears 90 times where independence predicts 30. A case buyer is three times as likely as an average shopper to add a protector. That is a rule worth testing as a bundle or a cart suggestion.
Why high confidence without lift is a false signal
Now take a charging cable that appears in 600 of the same 1,000 orders, and 130 of the 200 case orders.
| Rule | Confidence | Base rate of B | Lift | Expected vs observed |
|---|---|---|---|---|
| Case → protector | 45% | 15% | 3.00 | 30 expected, 90 observed |
| Case → cable | 65% | 60% | 1.08 | 120 expected, 130 observed |
Sorted by confidence, "case → cable" wins: 65% against 45%. But 60% of all orders contain a cable anyway, so a case in the basket barely changes the odds. Recommending the cable to case buyers would mostly show it to people who were going to buy it regardless.
This is the mistake Brin and colleagues warned about, and it shows up whenever one item is a bestseller: any rule that ends in that item gets high confidence. The decision rule:
- Rank candidate rules by lift, not confidence.
- Use confidence afterwards to estimate how many baskets a suggestion would hit.
- Drop rules whose consequent is in a large share of all orders unless lift is clearly above 1.
Small counts and the minimum-support rule
Lift has the opposite weakness: it explodes on rare items. Suppose a niche lens appears in 5 orders, a tripod mount in 6, and 3 orders contain both:
- Lift = (3 ÷ 5) ÷ (6 ÷ 1,000) = 100.
- Expected orders with both if independent = 5 × 6 ÷ 1,000 = 0.03.
A lift of 100 from three orders is noise. Two guards fix this:
- Minimum support. Only evaluate pairs that appear together in at least a fixed number of orders, for example 20 or 30, chosen before you look at results.
- A significance check. A chi-squared test on the 2 × 2 table (A yes/no × B yes/no) gives 176.5 for case and protector and 2.6 for case and cable. With 1 degree of freedom, the 5% critical value is 3.841 (NIST/SEMATECH e-Handbook), so only the first association is unlikely to be chance. The test is unreliable when expected counts are tiny, as in the lens example, which is why minimum support comes first.
Product affinity vs RFM and average order value
| Product affinity analysis | RFM | Average order value | |
|---|---|---|---|
| Unit of analysis | Pairs or sets of items | Customers | Orders |
| Question | Which items go together? | Which customers are valuable or slipping? | How much is a typical order worth? |
| Output | Rules ranked by lift | Customer groups by recency, frequency and money | One average per period |
| Typical action | Bundles, cart suggestions, store layout | Win-back, loyalty offers | Free-shipping thresholds, upsells |
The three work together. Affinity rules tell you what to suggest, RFM tells you whom to suggest it to, and AOV tells you whether the suggestion changed basket value. Cross-selling is the tactic; affinity analysis is the measurement behind it. For customer-level questions such as who is likely to buy again, see customer data analytics.
How to run it step by step
- Export order lines. One row per item per order: order ID, item ID or category, date. Remove refunded orders and test orders.
- Choose the level. Individual SKUs give thin counts; categories (cases, protectors, cables) give stable ones. Start at category level.
- Fix the window. Use a period long enough to reach your minimum support, such as 90 days, and keep it constant when you compare.
- Count pairs and compute support, confidence and lift for every pair above the minimum support.
- Filter: lift above a threshold you set in advance (for example 1.5) and the chi-squared value above 3.841.
- Test before rolling out. An affinity rule is a correlation. Whether showing the suggestion raises basket value is a separate question that needs a controlled comparison.
Measuring basket behaviour with TapCub
TapCub has no built-in market basket report. What it gives you is the order data and the before/after measurement. The 1,000-order example would run like this:
- Record orders with an order ID. All-platform analytics › Business › Commerce & revenue reads purchase events that carry an order ID, revenue and currency, and shows revenue, orders, buyers and average order (revenue ÷ orders).
- Send line items as events. The purchase event carries the order total, not the items. To count pairs, send one event per order line (for example
order_item) with the order ID and item or category as properties. - Count pairs with SQL. In All-platform analytics › Behavior › Metrics & SQL, the SQL tab runs one
SELECTorWITHstatement against the project's events view; a self-join on order ID returns pair counts, and the result can be exported as CSV (up to 50,000 rows). Support, confidence and lift then take a few spreadsheet formulas. - Measure the change. After launching a bundle, compare average order value on Commerce & revenue for the periods before and after, and use All-platform analytics › Users › Segments & tags (including the RFM groups) to see which customers take it up.
TapCub does not show product recommendations on your store or run the controlled test; it measures what happens after you do.
Sources
- R. Agrawal, T. Imieliński, A. Swami, "Mining association rules between sets of items in large databases", SIGMOD 1993, dblp record.
- S. Brin, R. Motwani, C. Silverstein, "Beyond market baskets: generalizing association rules to correlations", SIGMOD 1997, dblp record.
- NIST/SEMATECH e-Handbook of Statistical Methods, Critical values of the chi-square distribution.
Was this explanation clear?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Product Adoption Consultant
Explores customer onboarding, live conversations, and self-service, turning common usage questions into practical guidance and improvements.