What sample size means in an A/B test
An A/B test needs enough visitors in each variant to tell a real difference from chance. How many depends on three choices: the smallest effect worth detecting, how sure you want to be that a winner is not a fluke (the confidence level) and how likely the test should be to find a real effect of that size (the power).
Small effects need many visitors. The sample grows with one over the squared difference, so halving the effect you want to detect roughly quadruples the visitors you need.
The sample size formula
This is the standard formula for comparing two proportions with a two-sided z-test, the same test the A/B test calculator runs. The significance part uses the average of both rates, as the test does when it assumes there is no difference; the power part uses each rate’s own variance.
The calculator sizes the test for an increase of the size you enter. The duration is the total sample divided by the visitors who enter the test each day, rounded up to whole days.
p₁ = baseline rate, p₂ = rate to detect, p̄ = (p₁ + p₂) ÷ 2 n = (zα × √(2 × p̄ × (1 − p̄)) + zβ × √(p₁ × (1 − p₁) + p₂ × (1 − p₂)))² ÷ (p₂ − p₁)² zα = 1.645 (90%), 1.960 (95%), 2.576 (99%), two-sided zβ = 0.842 (80% power), 1.282 (90% power) Days = n × variants ÷ visitors per day, rounded up Baseline 5%, relative effect 20%: p₂ = 6%, p̄ = 0.055 95% confidence, 80% power: n = (1.960 × √0.10395 + 0.842 × √0.1039)² ÷ 0.01² = (0.6319 + 0.2713)² ÷ 0.0001 = 8,158 per variant 2 variants at 1,000 visitors a day: 16,316 ÷ 1,000 = 16.3, so 17 days
Planning tests with clients
Agree the baseline, the smallest effect that would change a decision and the confidence level with the client before the test starts. If the answer is months of traffic, test a bolder change, a page with more visitors or a step closer to the sale, rather than lowering the bar once the test is running.
- Take the baseline from the same page over a recent, normal period
- Choose the minimum detectable effect from what would be worth acting on, not from the lift you hope for
- Round the duration up to whole weeks, so every day of the week is in the sample
- Do not stop early because the result looks good; read it once each variant has its sample
- With more than two variants, every comparison with the original adds a chance of a false winner, so consider a stricter confidence level