Image: Zuko.io Images (CC BY 2.0)How many visitors does an A/B test need
An online shop converts 3 per cent of its visitors into buyers. A designer proposes a new product page and believes it will do better. The team agrees to run an A/B test: half the visitors see the old page, half see the new one, and after a while the team compares the two conversion rates. The question that decides whether the test is worth anything is asked before it starts. How many visitors does each version need?
The answer depends on three things: the current rate, the smallest improvement the team would act on, and how sure it wants to be. Unit 14 of the masterclass treats the A/B test as the start-up's basic experiment, and this is its central calculation.
Why a few hundred visitors tell you nothing
Suppose the team shows each page to 500 visitors. The old page converts 15 of them, which is 3 per cent, and the new one converts 20, which is 4 per cent. The new page looks a third better. Now imagine the same two pages were identical. With 500 visitors and a true rate of 3 per cent, the number of buyers is a random quantity with a mean of 15 and a standard deviation of about 3.8, so one version getting 15 and the other 20 is an ordinary fluctuation. The team has learned nothing, and if it ships the new page on that evidence it has made a decision by coin toss.
The noise in a conversion rate measured on \(n\) visitors shrinks with the square root of \(n\). To halve the noise you need four times the visitors. To detect a small difference between two noisy rates you need enough visitors that the difference you care about is several times larger than the noise.
The calculation
Write \(p\) for the current rate, 0.03, and \(\delta\) for the smallest change worth detecting, 0.005, which is the half-point lift from 3 to 3.5 per cent. The standard approach fixes two risks: the chance of declaring a difference when there is none, usually set at 5 per cent, and the chance of missing a real difference of size \(\delta\), usually set at 20 per cent, so that the test has an 80 per cent chance of finding the effect if it exists. With those settings the number of visitors needed per version is approximately
\[ n \approx \frac{2\,(1.96 + 0.84)^2\, p\,(1 - p)}{\delta^{2}} = \frac{2 \times 7.84 \times 0.0291}{0.000025} \approx 18{,}000. \]Each version needs about 18,000 visitors, so the test needs about 36,000 in all. A shop with 2,000 visitors a day runs it for about three weeks. Evan Miller's sample size calculator, the weekly tool of Unit 14, does this arithmetic and gives a slightly different figure because it uses the exact formula, but the order of magnitude is the point.
Now change the inputs. If the team would only act on a lift to 4 per cent, \(\delta\) doubles and the sample size falls by a factor of four, to about 4,500 per version. If it wants to detect a lift to 3.25 per cent, \(\delta\) halves and the sample size quadruples, to about 73,000 per version, which at 2,000 visitors a day is ten weeks. The smallest effect worth detecting is a business decision, and it is the input that most determines whether the test is feasible at all.
What the result means
When the test ends, the team will have two rates and a confidence interval for their difference. A 95 per cent confidence interval is a range computed from the data by a method that, in 95 of every 100 tests run this way, produces a range containing the true difference. If the interval for the new page minus the old runs from 0.1 to 0.9 percentage points, the new page is very probably better, and by somewhere in that range. If it runs from minus 0.3 to plus 0.5, the test has not decided, and the right conclusion is that the pages are too close to tell apart at this sample size, not that they are the same.
Why peeking misleads
The most common mistake in practice is to check the results every day and stop as soon as the difference looks significant. It feels efficient. It is wrong, for a reason that takes one sentence: the 5 per cent risk of a false positive applies to a test that is examined once, at the end, and a test that is examined twenty times along the way gets twenty chances to cross the line by luck. Evan Miller's page How Not To Run an A/B Test simulates this and finds that a test of two identical pages, checked daily and stopped at the first significant result, declares a winner far more often than one time in twenty. The false positives then get shipped, and the team's record of improvements fills up with changes that did nothing.
The remedy is the one the calculation gave you. Decide the sample size before the test starts, run until you reach it, and look once. Teams that need to stop early for good reasons use methods designed for repeated looks, which spend the 5 per cent risk across the checks, at the cost of needing more visitors in total.
What the test cannot tell you
An A/B test answers one question about two versions for the visitors who happened to arrive during the test. It does not say why the new page worked, whether it will keep working when the novelty wears off, or whether the visitors in a Christmas week behave like the ones in March. It also cannot measure what did not happen in the test: a page that raises conversion by half a point and doubles the return rate a month later has passed its A/B test and failed the business. Unit 3 puts the conversion funnel in the context of what a customer is worth over the years, which is the number the test should be serving.
Unit 14 works this calculation as its second worked case, derives the formula in a Case in Detail, and sets the A/B test among the other experiments a start-up can run, from the interview to the landing page to the randomized trial. The research spotlight of the unit reports what happened when founders themselves were taught to treat their ideas as hypotheses to be tested in this way.


