
A/B Test Sample Size: How to Calculate It Before You Launch

Your A/B test sample size is the number of visitors each variation needs before the result can be trusted. You get it from four inputs: your baseline conversion rate, the smallest lift worth detecting, your significance level and your statistical power. Fix those numbers before launch, and a platform that sets up tests without developers, like Stellar, lets you run to that number rather than stopping when the dashboard looks good.
This guide covers what each input means, the formula, a worked example with real numbers, how to turn the sample into a test duration, and the mistakes that make a "winning" test unreliable.
TL;DR
- Sample size is per variation, and it is decided before the test starts, from baseline rate, minimum detectable effect (MDE), significance level and power.
- The smaller the lift you want to detect, the more traffic you need, and the relationship is steep: halving the MDE roughly quadruples the sample.
- Example: a 3% baseline and a 10% relative lift need 53,208 visitors per variation at 95% significance and 80% power.
- Run the test in full weeks, do not stop at the first significant reading, and check for sample-ratio mismatch.
- Reaching the sample size tells you the test could detect your target effect. It does not tell you the effect is big enough to matter commercially.
Table of Contents
- What sample size means in an A/B test
- The four inputs that determine sample size
- The formula, step by step
- From sample size to test duration
- Mistakes that make results unreliable
- What reaching the sample size does and does not tell you
- Our perspective
- Plan your next test in Stellar
- FAQ
- Sources
What sample size means in an A/B test
In an A/B test, every visitor is randomly assigned to the control or to a variation, and each one either converts or does not. Sample size is how many of those visitors you collect in each group before you read the result. With too few, normal random noise can look like a win or hide a real one. With too many, you spend traffic and calendar time you could have used on the next idea.
The reason to fix the number in advance is a statistical one. Dashboards report a significance figure that assumes you look once, at the end. If you check repeatedly and stop when the number crosses the line, the chance of a false positive climbs well above the level you chose. A well-known explanation of repeated significance testing errors puts the remedy simply: decide on a sample size in advance and wait until the experiment is over before you believe the result.
So the sample size is not an estimate you refine as you go. It is the stopping rule.
The four inputs that determine sample size
Baseline conversion rate
This is the current conversion rate of the page or step you are testing, measured for the same audience and the same event you will use in the test. A mismatched baseline, such as sitewide conversion when you are testing one landing page, is one of the most common reasons a plan goes wrong. A page converting at 3% and one converting at 12% need very different sample sizes for the same relative lift.
Minimum detectable effect (MDE)
The MDE is the smallest change you want the test to be able to detect. It is a planning choice, not a prediction. State it in one unit and stick to it, because relative and absolute MDE are easy to confuse. As one worked guide shows, at a 3% baseline a 10% relative lift means moving from 3.0% to 3.3%, which is an absolute increase of 0.3 percentage points.
MDE is the lever with the biggest effect on your traffic bill. Sample size scales with the inverse square of the effect, so detecting half the lift takes about four times the visitors. Pick the smallest lift that would change a business decision, not the smallest lift you can imagine.
Significance level (alpha)
Significance level is the false-positive rate you accept. The usual choice is 5%, shown as 95% significance. Tightening it to 1% protects you from more false wins but raises the sample you need. If you want a deeper walk-through of what the number means in practice, our guide to A/B test significance for marketers covers it.
Statistical power
Power is the probability that the test detects a real effect of your chosen MDE. The common target is 80%, meaning that if the true lift equals your MDE, you will catch it four times out of five. Higher power needs more traffic. We go further into the mechanics in understanding statistical power.
Variability and traffic split
Two more factors sit behind the four inputs. The Stanford-hosted guide to controlled experiments on the web explains that standard error shrinks with the square root of sample size, and that a metric with more variability has less power at a given sample. This matters for non-conversion metrics like revenue per visitor, where a few large orders create a lot of spread. A sample that is enough for conversion rate may be too small for revenue.
Split traffic evenly. The experiment-planning material from Kohavi and Longbotham notes that an equal split between two variants gives the most power for a fixed total number of users.
The formula, step by step
For a conversion-rate test with two equal groups, let p1 be the baseline rate and p2 the rate you hope to reach (baseline plus the MDE). The visitors needed per group are:
n = (z(1-α/2) + z(1-β))² × [p1(1-p1) + p2(1-p2)] ÷ (p2 - p1)²
Round the result up. The z values come from the normal distribution: 1.96 for 95% two-sided significance and about 0.84 for 80% power. The structure of the formula tells you everything you need to plan around: the numerator grows with variability and with stricter alpha or higher power, and the denominator is the squared gap between the two rates.
For continuous metrics such as revenue per visitor, a 2023 paper on sample-size calculations for A/B testing gives the per-arm approximation n = 2σ²(z(1-α/2) + z(1-β))² ÷ δ², where δ is the MDE and σ is the standard deviation of the metric. At 5% significance and 80% power, it reduces to the rule of thumb of roughly 16σ²/δ² per arm.
A worked example
Take a landing page converting at 3% and a goal of a 10% relative lift, so p1 = 0.030 and p2 = 0.033. With 95% two-sided significance and 80% power, the worked example in this guide arrives at 53,208 visitors per group, or 106,416 in total.
Now see what the MDE does. If you only care about a 20% relative lift (3.0% to 3.6%), the gap doubles, and the required sample falls to roughly a quarter of that. If you chase a 5% lift (3.0% to 3.15%), it grows to roughly four times as much. The same page, the same baseline, wildly different commitments.

Check your arithmetic
After computing by hand, confirm with a calculator, and make sure it is configured the same way: same MDE units (relative or absolute), same test sidedness, same variance method, same alpha and power. Differences of a few percent between calculators usually come from those settings, not from errors. Our overview of sample size calculators explains what to set, and our guide to calculating power for A/B tests shows the math behind the numbers.
From sample size to test duration
A sample size means little until you turn it into days. The calculation is simple: divide the total sample by the eligible visitors per day that will actually enter the test.
Using the example above, 106,416 visitors in total at 5,000 eligible visitors a day takes about 21.3 days. Round up to full weeks, which gives three weeks. The Stanford-hosted guide recommends running experiments for at least one week, then in additional multiples of a week, to capture day-of-week effects. Weekday and weekend visitors often behave differently, and a test that ends mid-week over-weights some days.
If the answer is far longer than you can wait, you have four honest options:
- Accept a larger MDE and test bolder changes.
- Move the test to a higher-traffic page or an earlier funnel step with a higher baseline rate.
- Use a metric with less variability, or restrict the analysis to users who actually saw the changed element. The Stanford guide notes that analyzing only exposed users can improve sensitivity without extending the test.
- Lower power or loosen significance only if the decision is cheap and reversible, and say so up front.
The traffic estimate itself needs care. Count visitors, not page views, and count only those who qualify for the experiment. If your traffic estimate is rough, analyzing your website traffic by source and landing page gives you a better daily figure before you commit to a timeline. For real-world durations, our data from 450 tests on how long to run an A/B test is a useful benchmark.
Mistakes that make results unreliable
A correct sample size still does not protect you from a sloppy run. These are the failures that come up most:
- Stopping at the first significant reading. In a fixed-horizon test, the plan is the sample size. Interim peeks inflate false positives.
- Mixing relative and absolute MDE. Entering 10% as an absolute lift on a 3% baseline asks for 13%, a very different test.
- Underpowering. Running a test that was never big enough to see a realistic effect, then calling a flat result "no difference."
- Testing many variations or metrics without correction. Each extra comparison raises the odds of a fluke winner, a problem the Stanford-hosted guides call out as multiple comparisons.
- Sample-ratio mismatch. If you planned a 50/50 split and the actual counts are visibly off, something is broken in assignment or tracking, and the result should not be trusted until you find it.
- Contamination. Visitors who see more than one variation blur the difference between groups.
- Changing the allocation mid-test. The same experiment guides advise running control and treatment concurrently and warn that shifting traffic percentages during a test can distort comparisons.
A useful habit: write the sample size, MDE, metric and end date in your test brief before launch. It makes stopping early an explicit decision rather than a drift.
What reaching the sample size does and does not tell you
When you hit the planned sample, the test has done its job: it could detect an effect of the size you named. The 2023 sample-size paper draws a clear line between the design MDE, a planning assumption, and the smallest observed difference that happens to reach significance. A result can be statistically significant and still too small to pay for the engineering, the design time or the added complexity.
So read the result in two steps. First, is it significant at your planned level? Second, is the confidence interval around the lift entirely above the size that matters to the business? Our piece on when statistically significant results should not make marketers ship walks through that second step, and interpreting statistical significance in A/B test results helps you read the output.
Also remember the limit in the other direction: reaching the sample size says nothing about effects smaller than your MDE. A flat result means you did not find a lift of the size you planned for, not that no difference exists.
Our perspective
We built Stellar for marketers who want to run experiments without waiting on a developer, and sample size is where most of those experiments are won or lost before a single visitor arrives.
Our view is that the number should be a decision, not a surprise. Decide the lift that matters, compute the traffic it needs, and compare that with what your page actually gets. If the two do not match, change the test, not the rules. A bold change on a high-traffic page will teach you more in three weeks than a button tweak on a quiet page will in three months.
That is also why we care about a lightweight script and real-time analytics. Our script is 5.4KB, so the testing layer stays out of the way of the experience you are measuring, and live reporting lets you watch progress toward your planned sample without being tempted to call it early.
Juan
Plan your next test in Stellar
Stellar is an A/B testing platform with a no-code visual editor, advanced goal tracking and real-time analytics, built for marketers and growth teams at small and mid-sized businesses. Pricing is tiered by monthly tracked users: Sandbox is $0 per month, Plus is $29 per month, Pro is $99 per month and Scale is $399 per month, with Enterprise available at an unpublished price. The free plan is for businesses under 25,000 monthly tracked users, which is enough to run a properly sized test on a typical landing page. See the plans on the Stellar site.

FAQ
How many visitors do I need for an A/B test?
There is no single number, because it depends on your baseline rate and the lift you want to detect. As a reference point, a 3% baseline with a 10% relative lift needs 53,208 visitors per variation at 95% significance and 80% power. Lower baselines and smaller lifts push the number up fast.
Is a minimum of 100 conversions per variation enough?
It is a rough floor that some practitioners use, not a substitute for the calculation. In the worked example, 53,208 visitors at 3% is about 1,600 conversions per variation, far above 100. Compute the sample from your MDE and power, then treat conversion counts as a sanity check.
Can I stop a test early if the result is already significant?
Not in a fixed-horizon test. Repeated checking raises the false-positive rate above the level you chose. Run to the planned sample, in full weeks, and then read the result.
What if I don't have enough traffic?
Test a bigger change so a larger MDE is justified, move to a page or funnel step with more traffic or a higher baseline, or use a less variable metric. Each of these shrinks the sample you need without bending the statistics.
Sources
- How Not To Run an A/B Test
- Practical Guide to Controlled Experiments on the Web
- Online Controlled Experiments and A/B Tests
- All about Sample-Size Calculations for A/B Testing
- A/B Test Sample Size and Duration: How to Calculate Them
