Sub topic 11
Testing with holdouts and A/B tests
This chapter assumes you know what a segment and a decision rule are, and that you can read basic Python. It also assumes you know conversion rate and the idea of a statistical significance test. The next chapter covers how to compute and report incremental lift. This chapter covers how to design the test so that the lift can be measured at all.
Why personalisation needs a test
A personalised campaign usually looks good in a report. Customers in the "high value" segment convert at 8%, and the rest convert at 2%. That gap does not show that the personalisation worked. High-value customers were probably going to buy anyway. The question that matters is causal: what happened to these customers compared with what would have happened if you had done nothing, or done the default thing?
Randomisation is the way to answer that. If you assign customers to treatments by chance, the groups differ only by chance, apart from the treatment itself. Any consistent difference in outcome can then be credited to the treatment.
Two kinds of comparison
Personalisation programmes use two related designs. They answer different questions.
| Design | Compares | Question it answers |
|---|---|---|
| A/B test | Variant A against variant B, both sent | Which content or rule performs better? |
| Holdout | Personalised treatment against no treatment, or against a generic default | Is the whole personalisation programme adding value? |
An A/B test tells you that "new arrivals" beats "discount banner" for the lapsed segment. It does not tell you whether sending either message beats sending nothing. A holdout does that. The holdout group is a randomly chosen set of customers who are deliberately kept out of the personalised experience.
There are two common holdout types:
- Control holdout (no-send): the group receives no message at all. This measures the total effect of the message.
- Generic holdout: the group receives a non-personalised default, such as the standard newsletter. This measures the effect of personalisation itself, separate from the effect of simply contacting someone.
Choose deliberately. Many programmes report a large "lift" that is really the value of sending an email, not the value of making it personal.
A universal holdout is a small group, often 2% to 10% of the audience, excluded from all personalisation for a long period such as a quarter. It measures the cumulative value of the whole programme and catches problems that single-campaign tests miss.
The shape of a test
Write down the hypothesis, the single primary metric, the minimum effect you care about, and the end date before launch. Changing any of these after you see data is how false wins get reported.
Randomise the right unit
The unit of randomisation is the thing you assign to an arm. In personalisation it is almost always the customer, not the email, session or page view. If you randomise per message, the same person can receive the treatment on Monday and the control on Tuesday. Their behaviour then mixes both experiences, and your arms are contaminated.
Assignment should also be deterministic: the same customer always lands in the same arm for a given experiment. A hash of the customer ID and the experiment name gives you that without storing a lookup table. Including the experiment name matters. If you hash only the ID, the same customers fall into the holdout in every test, and the test results become correlated.
import hashlib
def assign(customer_id, experiment, arms):
"""arms maps arm name to share of traffic; shares must sum to 1."""
key = f"{experiment}:{customer_id}".encode("utf-8")
bucket = int(hashlib.sha256(key).hexdigest(), 16) % 10_000
position = bucket / 10_000
cumulative = 0.0
for name, share in arms.items():
cumulative += share
if position < cumulative:
return name
return list(arms)[-1]
arms = {"personalised": 0.45, "generic": 0.45, "holdout": 0.10}
for cid in [101, 102, 103, 104, 105]:
print(cid, assign(cid, "spring_winback_2026", arms))Run it twice and you get identical output. That repeatability is the property you need when a customer appears in several systems, such as the email platform, the website and the app. Each system can compute the same assignment from the same ID.
Sizing the test
Underpowered tests are the most common reason personalisation tests are inconclusive. Conversion differences caused by content are usually small, often a relative lift of 5% to 15%, so you need many customers per arm.
The function below uses the standard two-proportion formula. It returns the customers needed in each arm.
from math import ceil
from statistics import NormalDist
def sample_size_per_arm(p_base, relative_lift, alpha=0.05, power=0.8):
p_new = p_base * (1 + relative_lift)
z_alpha = NormalDist().inv_cdf(1 - alpha / 2)
z_power = NormalDist().inv_cdf(power)
variance = p_base * (1 - p_base) + p_new * (1 - p_new)
return ceil(((z_alpha + z_power) ** 2) * variance / (p_new - p_base) ** 2)
print(sample_size_per_arm(0.04, 0.10))With a 4% baseline conversion and a hoped-for 10% relative lift (4.0% to 4.4%), this prints about 39,500 customers per arm. Halving the lift you want to detect roughly quadruples the requirement. This is why a segment of 3,000 customers can almost never support a test of a small effect.
It also explains the holdout trade-off. A 10% holdout of a 500,000-customer audience gives 50,000 customers, which is enough for this example. A 2% holdout gives 10,000, which is not. A smaller holdout costs less revenue but takes longer, or never reaches, a clear answer.
Check the split before reading results
Before you look at outcomes, confirm that the arms contain roughly the sizes you intended. If you assigned 50/50 and observed 52,000 against 48,000, something is wrong. This is called a sample ratio mismatch (SRM). Typical causes are a bug that drops treated customers from logs, a suppression rule that applies only to one arm, or consent filtering that removes more people from one group.
from statistics import NormalDist
def srm_p_value(n_a, n_b, expected_share_a=0.5):
n = n_a + n_b
expected = n * expected_share_a
std = (n * expected_share_a * (1 - expected_share_a)) ** 0.5
z = (n_a - expected) / std
return 2 * (1 - NormalDist().cdf(abs(z)))
print(round(srm_p_value(52_000, 48_000), 6))
print(round(srm_p_value(50_150, 49_850), 3))The first call returns a p-value near zero, so you must investigate before trusting any metric. The second returns about 0.55, which is normal random variation. A common alarm threshold is p below 0.001, because you will run this check on many tests.
Common errors in personalisation tests
Peeking and stopping early. Checking the p-value daily and stopping when it dips below 0.05 inflates false positives well above 5%. Fix the duration in advance. Run for whole weeks so each weekday is represented equally.
Segment effects found after the fact. If you slice results into 20 segments and one shows a significant win, that is expected by chance. Declare the segments before the test, or treat post-hoc findings as hypotheses for a new test.
Comparing against the wrong baseline. Measuring the personalised group against customers who did not qualify for the segment is not an experiment. Qualification must be decided first, and then qualifying customers are randomised into treatment and holdout.
Interference between customers. If a discount is shared, or if limited stock is allocated to the treatment group, the holdout customers are affected indirectly. Prefer randomising at a higher level, such as the household or region, when this is likely.
Novelty effects. A new banner often wins in the first week because it is new. Look at whether the lift persists in later weeks.
Holdouts that leak. If the holdout customers still receive personalised content through another channel, such as the app or on-site recommendations, the comparison is diluted. Apply the holdout flag in every system that personalises.
Consent and eligibility filtering after assignment. Filter by consent first, then randomise. If you randomise first and then drop customers without consent, the arms can end up with different compositions.
Holdouts and adaptive selection
If you use a bandit to choose between variants, covered in the decisioning chapter, you still need a fixed holdout. A bandit shifts traffic toward whichever variant is currently doing well. It optimises the choice among variants, but it does not tell you whether the choice beats doing nothing. Reserve a fixed share, say 5% to 10%, that never goes through the bandit and receives the default. Keep that share constant for the whole period, and the comparison stays clean.
Reading the outcome
At the planned end date, compare the primary metric between arms and report the difference with a confidence interval, not only a p-value. A result such as "+0.3 percentage points, 95% interval from 0.1 to 0.5" tells the business both the likely size and the uncertainty. Translating this into incremental revenue per customer is the subject of the next chapter.
Exercise
Your team sends a "we saved your basket" email to the lapsed segment. The report shows 6% of recipients bought within 7 days, and 1.5% of non-recipients in the wider customer base bought in the same period. A colleague says personalisation lifted conversion by 4.5 points. Explain why this conclusion is unsafe, and describe the test you would run instead, including the unit of randomisation, the arms, and one check to run before reading results.
Show answer
The comparison is not randomised. Lapsed customers who got the email differ from the wider base in many ways, such as intent and recent activity, so the gap mixes selection with the effect of the email. The test should first define eligible lapsed customers, filtered by consent. Then it should randomise those customers, with the customer as the unit and a deterministic hash of customer ID plus experiment name. Arms would be personalised email, a generic default email (to isolate the effect of personalisation), and a no-send holdout (to measure the effect of contacting at all). Size the arms with a power calculation in advance, fix the duration at whole weeks, and name one primary metric. Before reading outcomes, run a sample ratio mismatch check to confirm the arm sizes match the planned split.