The sample size is the number of visitors, sessions or users an experiment needs in order to detect, with a given probability, a real difference between variants of at least the size we care about. It is calculated before launching the test, using the baseline conversion rate, the minimum detectable effect, the significance level and the statistical power. Getting it right prevents decisions based on insufficient data and reduces the temptation to stop an experiment when the numbers do not yet say anything meaningful.

How it works

The core idea is simple: the smaller the difference we want to detect, the more data we need to tell it apart from random noise. That noise is always present, because two groups of users never behave exactly the same, even when they receive the same experience. If variant B converts slightly better than variant A, that advantage can be hidden by natural fluctuations when the sample is too small.

Four variables determine the sample size. The first is the baseline rate, meaning the current conversion of the page or step we are optimising. A very low rate requires large samples, because there are few conversion events to compare. The second is the minimum detectable effect, the smallest improvement that truly matters to the business. The third is the significance level, usually set at 5 % as a common reference value, which controls the probability of declaring a difference that does not really exist. The fourth is statistical power, commonly set at 80 %, which indicates the probability of detecting the effect if it exists.

With these four inputs we obtain a number per variant. To compare two proportions, a common approximate formula is n equals (Z for 1 minus alpha over 2 plus Z for power) squared, multiplied by the sum of p1 times (1 minus p1) and p2 times (1 minus p2), all divided by the squared difference between p2 and p1. Most experimentation platforms and online calculators follow this logic, although some use different methods, so it is worth understanding the assumptions behind the figure.

Practical example

Imagine that an online shop has a 4 % conversion rate on its product page and wants to detect an absolute improvement of one point, moving to 5 %. With alpha of 5 % two-sided (Z of 1.96) and power of 80 % (Z of 0.84), the sum of the Z values is 2.8, and squared that gives 7.84.

The variance for each group would be 0.04 times 0.96, which is 0.0384, and 0.05 times 0.95, which is 0.0475. Their sum is 0.0859. Multiplying 7.84 by 0.0859 gives roughly 0.6735. Dividing by 0.01 squared, which is 0.0001, yields about 6,735 users per variant, or a little over 13,400 in total.

If that shop hypothetically receives 2,000 daily visits to that page and splits traffic 50/50, each variant would get about 1,000 visits a day. The test would need around 7 days, but it is wise to run at least two full weeks to cover differences between weekdays and weekends. If instead we wanted to detect only half a point, the required sample would roughly quadruple, and the test would take considerably longer.

How to apply it step by step

  1. Define the primary metric precisely, for example completed purchases per session or confirmed sign-ups, and measure its baseline using several weeks of data to account for seasonality.

  2. Set the minimum detectable effect based on business criteria, not on what you would like to see. Ask which improvement would justify the cost of implementing the change.

  3. Fix the significance level and the power. If there is no specific reason to change them, keep standard values and document them in the hypothesis.

  4. Calculate the sample size per variant with the formula or a reliable calculator, then add all variants together to get the total required.

  5. Estimate the duration by dividing the total by the daily traffic that will actually enter the experiment, taking into account the share of traffic allocated to it.

  6. Round the duration up to full weeks and check that the test will not run so long that campaign, product or seasonal changes contaminate the results.

  7. Record the calculation before launch and do not change the plan midway. If you need a different minimum effect, treat it as a new experiment.

Common mistakes

The most frequent error is skipping the sample size calculation and deciding when to end the test by checking results every day. This practice, known as peeking, greatly increases the chance of finding a false difference, because every review is a new opportunity for chance to look like a win.

Another common problem is setting an overly optimistic minimum effect. If the calculation assumes a 30 % improvement when a realistic one is 3 %, the test may look conclusive with very little data, yet the result is unlikely to hold up. It is also easy to use a baseline taken from another page or another period instead of the real current rate.

Mistakes also happen when the number of variants is ignored. If a test has four versions, each compared against the control, the risk of false positives grows, and corrections or fewer comparisons are needed. Finally, many teams calculate the size thinking only about users and not about events, when in many cases the number of conversions is what really drives the precision of the estimate.

Best practices

Treat sample size as part of the hypothesis rather than as a technical formality. A well-formed hypothesis states what change is made, which metric it should affect and what minimum improvement would justify implementing it. With that information, the calculation becomes almost mechanical.

Plan with a margin. If the calculation indicates 6,700 users per variant and traffic is irregular, it is sensible to allow a buffer and not stop the test on the day the minimum is first reached. Make sure traffic allocation is random and stable throughout the whole period.

When traffic cannot reach the required size, do not force the test. Reasonable alternatives include grouping similar pages, testing bolder changes that may produce larger effects, focusing on process metrics with more volume, or using qualitative research to learn before quantifying. Always document the decision and the limitations of the analysis.

Frequently asked questions

Can I use an online calculator instead of the formula?

Yes, and it is the most common approach. What matters is understanding the inputs it asks for, especially whether the calculation is for a proportion or a mean, whether the test is one-sided or two-sided, and which baseline rate you enter. A well-used calculator gives the same order of magnitude as the formula, although small differences can appear depending on the method.

What if the result is a very large number?

A huge sample size usually means the minimum effect is too small for the available traffic, or the baseline rate is very low. Before discarding the test, check whether the metric is appropriate, whether the change can be made more impactful, or whether it is better to measure an intermediate metric that generates more events.

Can I change the sample size during the experiment?

It is not advisable to modify the plan to make the result look better. If you change the minimum effect, the power or the duration based on what you are seeing, you are altering the rules of the analysis after the fact, which invalidates the guarantees of the test. If a change is genuinely justified, the honest approach is to document it and treat the new analysis with caution.