Sub topic 11
Testing what works: A/B tests and incrementality
This chapter assumes you know the funnel stages, can calculate conversion rates, and have read the chapter on attribution. Attribution tells you which touchpoints appear on the path to a sale. It cannot tell you whether those touchpoints caused the sale. Experiments can.
Why experiments come after attribution
A customer who clicked a retargeting ad and then bought might have bought anyway. Attribution gives that ad full credit under last-touch, and partial credit under multi-touch. Neither model asks the counterfactual question: what would have happened without the ad?
An experiment answers that question by splitting people into groups at random. One group gets the marketing action (the treatment). The other does not (the control). Because assignment is random, the groups are alike on average in everything except the treatment. Any difference in outcome can then be credited to the treatment.
Two kinds of experiment cover most marketing needs:
| Question | Method | Typical unit |
|---|---|---|
| Which version of a page, email, or ad performs better? | A/B test | Visitor, user, or email recipient |
| Does this channel or campaign create sales that would not otherwise happen? | Incrementality test | User, geographic region, or audience |
Designing an A/B test
An A/B test shows version A (control) to one random group and version B (variant) to another, then compares a single outcome metric.
Step 1: Write a hypothesis
State the change, the metric, and the expected direction. For example: "Replacing the long signup form with a three-field form will raise the visitor-to-lead conversion rate."
Step 2: Choose one primary metric
Pick the metric that matches the goal, before you see any data. For a landing-page test this is usually the visitor-to-lead rate from the funnel chapters. Add guardrail metrics, which are numbers that must not get worse. A shorter form may raise lead volume while lowering the share of leads that become sales-qualified, so lead quality is a sensible guardrail.
Step 3: Randomize correctly
Assign each person to a group by chance, and keep them in that group for the whole test. Assigning by a stable user identifier (hashing the ID) prevents the same person from seeing both versions on different visits.
import hashlib
def assign_variant(user_id: str, experiment: str) -> str:
key = f"{experiment}:{user_id}".encode("utf-8")
bucket = int(hashlib.sha256(key).hexdigest(), 16) % 100
return "B" if bucket < 50 else "A"
for uid in ["u1001", "u1002", "u1003", "u1004"]:
print(uid, assign_variant(uid, "short_form_test"))Including the experiment name in the hash means a user's assignment in one test does not predict their assignment in another.
Step 4: Decide the sample size before starting
Small differences need large samples. If you stop as soon as the result looks good, you inflate the chance of a false positive. Fix the sample size in advance from three inputs:
- The baseline rate, such as a current 3.0% visitor-to-lead rate.
- The minimum detectable effect (MDE), the smallest change worth acting on, such as a rise from 3.0% to 3.6%.
- The desired significance level (commonly 5%) and power (commonly 80%). Significance is the false-positive rate you accept. Power is the chance of detecting a real effect of at least the MDE.
The standard approximation for a two-proportion test is:
from math import ceil
from statistics import NormalDist
def sample_size_per_group(p1, p2, alpha=0.05, power=0.80):
z_alpha = NormalDist().inv_cdf(1 - alpha / 2)
z_power = NormalDist().inv_cdf(power)
variance = p1 * (1 - p1) + p2 * (1 - p2)
n = ((z_alpha + z_power) ** 2 * variance) / (p1 - p2) ** 2
return ceil(n)
print(sample_size_per_group(0.030, 0.036))This prints about 13,900 visitors per group. With 50,000 monthly visitors split evenly, that test needs roughly two to three weeks. Halve the MDE and the required sample roughly quadruples, which is why tests on small effects are often impractical for low-traffic sites.
Step 5: Run for full cycles
Run the test for whole weeks. Weekday and weekend behavior often differ, and a test that covers only Monday to Thursday can mislead you. Avoid launching during unusual periods, such as a sale, unless the result only needs to apply to that period.
Reading the result
After the test ends, compare the two rates and ask whether the gap is bigger than chance would explain.
from math import sqrt
from statistics import NormalDist
def two_proportion_test(conv_a, n_a, conv_b, n_b):
p_a, p_b = conv_a / n_a, conv_b / n_b
pooled = (conv_a + conv_b) / (n_a + n_b)
se = sqrt(pooled * (1 - pooled) * (1 / n_a + 1 / n_b))
z = (p_b - p_a) / se
p_value = 2 * (1 - NormalDist().cdf(abs(z)))
return p_a, p_b, p_value
p_a, p_b, p = two_proportion_test(420, 14000, 504, 14000)
print(f"A {p_a:.2%}, B {p_b:.2%}, lift {(p_b - p_a) / p_a:.0%}, p-value {p:.4f}")The output shows A at 3.00%, B at 3.60%, a 20% relative lift, and a p-value near 0.001. The p-value is the probability of seeing a gap at least this large if the two versions were truly identical. A value below your chosen significance level (0.05) means the result is statistically significant.
Two cautions apply when you read this number:
- A p-value is not the probability that B is better. It describes how surprising the data would be if there were no difference.
- Statistical significance is not business significance. A 0.05-point lift can be significant with millions of visitors and still not pay for the cost of the change. Report the size of the lift with a range, not only "significant".
Common A/B testing errors
- Peeking and early stopping. Described above. It produces winners that vanish when rolled out.
- Testing many variants or metrics. With 20 metrics at a 5% threshold, one will usually look significant by chance. Name one primary metric in advance and treat the rest as exploratory.
- Sample ratio mismatch. If you planned a 50/50 split and see 52/48 on tens of thousands of users, the assignment or tracking is probably broken. Check the split before trusting any result.
- Novelty effects. A new design may win simply because it is new. Run long enough for the effect to settle, and check whether the lift shrinks over time.
- Contamination. If people in the control group see the treatment through another channel, such as a shared link or a second device, the groups no longer differ cleanly.
- Wrong metric. A subject line that raises open rates may lower clicks or sales. Where you can, measure the outcome closest to revenue that the test has the volume to detect.
When A/B tests are not enough: incrementality
A/B tests compare two versions of something people will see anyway. They do not tell you whether the activity itself adds sales. Consider paid search on your own brand name. People searching your brand name were already looking for you. The ad captures many sales that would have come through the free result. Attribution reports a strong return, but the incremental effect, the extra sales caused by the spend, may be small.
Incrementality testing measures that extra effect by withholding the marketing from a control group.
Common designs
- Holdout test. Exclude a random share of your audience, say 10%, from a campaign. Compare conversions in the exposed and held-out groups. Platforms often offer this as a "conversion lift" study.
- Ghost ads or placebo ads. The control group is eligible to see an ad but sees a neutral one instead. This isolates the effect of the ad from the effect of targeting.
- Geo experiments. When individuals cannot be randomized, as with TV, radio, or billboards, split regions. Run the campaign in some regions and not others, with comparable regions matched on past sales.
Calculating incremental results
Suppose a retargeting campaign reaches 90,000 people and holds out 10,000.
treated_users, treated_conversions = 90000, 1980
holdout_users, holdout_conversions = 10000, 200
rate_t = treated_conversions / treated_users # 2.2%
rate_h = holdout_conversions / holdout_users # 2.0%
incremental_rate = rate_t - rate_h # 0.2 points
incremental_conversions = incremental_rate * treated_users
lift = incremental_rate / rate_h
share_incremental = incremental_conversions / treated_conversions
print(f"incremental conversions: {incremental_conversions:.0f}")
print(f"relative lift: {lift:.0%}")
print(f"share of reported conversions that were incremental: {share_incremental:.0%}")The campaign reports 1,980 conversions, yet only about 180 are incremental. The relative lift is 10%, and roughly 9% of the conversions the platform would claim were caused by the ads. If the campaign cost $9,000, the incremental cost per acquisition is $9,000 / 180 = $50, not the $4.55 that the reported conversions suggest.
This is the link back to unit economics. Use incremental conversions, not attributed ones, when you compute CAC for channels that mostly reach people who were likely to buy anyway.
Choosing between methods
| Situation | Best method |
|---|---|
| Comparing two page designs, subject lines, or ad creatives | A/B test |
| Deciding whether a channel deserves its budget | Holdout or geo experiment |
| Brand, TV, or other mass media with no user-level control | Geo experiment |
| Very low traffic, effects too small to detect | Larger changes, longer tests, or pre/post comparison with caution |
A pre/post comparison (before versus after a change) is a last resort. Seasonality, other campaigns, and market shifts all change results over time, and nothing separates them from your change.
Practical limits
- Holdouts cost money. The held-out group may buy less than it would have. Keep them small and short, and weigh that cost against the budget you might be wasting.
- Results are specific to the audience, offer, and time. A lift measured on new customers in spring does not automatically hold for existing customers in December.
- Incrementality for upper-funnel work, such as awareness, often takes weeks to appear. Match the test duration to the sales cycle you measured earlier.
- Record every test, including failures, with hypothesis, dates, sample sizes, and outcome. Otherwise teams repeat the same tests.
Exercise
A retargeting campaign reaches 45,000 people and holds out 5,000. The treated group produces 900 purchases and the holdout produces 80. (a) What are the two conversion rates? (b) How many of the 900 purchases were incremental? (c) The campaign cost $6,000. What is the cost per incremental purchase, and how does it compare to the cost per reported purchase?
Show answer
(a) Treated: 900 / 45,000 = 2.0%. Holdout: 80 / 5,000 = 1.6%. (b) The incremental rate is 0.4 points, so 0.004 × 45,000 = 180 incremental purchases. (c) $6,000 / 180 ≈ $33.33 per incremental purchase, compared with $6,000 / 900 ≈ $6.67 per reported purchase. The reported figure understates the real cost by a factor of five because 80% of the purchases would have happened anyway.
Exercise
You run an A/B test with a planned 50/50 split. After the test you find 31,000 users in A and 27,000 in B, and B shows a 15% higher conversion rate with p = 0.03. Should you ship B? Explain.
Show answer
Not yet. A 31,000/27,000 split is far from 50/50 and, at this sample size, is almost certainly not chance. This is a sample ratio mismatch, which signals a problem in assignment or tracking, such as a slower page losing B's visitors before the tracking tag fires. Any such bias could produce the apparent lift. Find and fix the cause, then rerun the test.