Summary of this article
- How trustworthy an A/B test is depends on writing down your decision rules before you start. Decide the primary metric, the difference you want to detect, the required sample size, the duration, and your stop conditions up front
- The required sample size is determined mostly by your "current conversion rate" and "the difference you want to detect." To detect a 20% improvement on a page with a 2.5% conversion rate, you need about 16,800 visitors per variation
- Once the test is running, first check that the traffic split isn't skewed and that conversions are recorded correctly. If something is off, fix the cause before you read any results
- Checking results repeatedly and stopping as soon as they look good greatly raises the chance that a change with no effect is declared a "win." In our worked example, checking every day and stopping produces about 27%
- You can verify statistical significance yourself with spreadsheet formulas. Look not only at the p-value but also at the range of the difference (the confidence interval), and you'll be less likely to misjudge
- Sort results into three outcomes, "adopt," "pass," and "redo," and keep a record for your next test
You understand what A/B testing is and the basic flow. But when you actually try to start, you get stuck on "How many people do I need to show it to?", "When do I stop?", and "Can I trust this difference?" Many people who are put in charge of A/B testing stumble right here.
Whether an A/B test's results are trustworthy depends less on difficult statistical knowledge than on whether you kept to what you decided before you started, until the end. If you change the rules midway, or stop the moment things look good, the conclusion can't be relied on no matter how correct the math is.
This article walks through how to run an A/B test in practice, in order, with worked calculations. For the basics, such as what A/B testing is, why it's needed, and what a p-value is, see What Is A/B Testing?. If you're new to this, reading that first will help. All numbers in this article are hypothetical numbers set up for explanation, and results calculated from them.
The Overall Flow of an A/B Test
An A/B test proceeds in the following six stages.
- Design: Put what you'll change, why, and what you'll judge by on a single sheet
- Calculate the required sample size and duration: Check whether enough data to judge can be collected in a realistic period
- Launch and check: In the first few days, confirm that the traffic split and the conversion records are correct
- Wait until the period ends: Even if you look at results midway, don't stop before the period you decided on
- Judge: Look at statistical significance and the range of the difference, then decide to adopt, pass, or redo
- Record and move on: Save the results and what you learned, and connect them to the next hypothesis
Of these, stages 1 and 2 have the biggest effect on how trustworthy the results are. If you skip them and launch, you end up deciding after the fact "which number to judge by" and "whether there's enough data," and you're easily pulled toward the conclusion you want to see.
1. Design: Write One Test Design Sheet
Before you launch, write out the following items on a single sheet. One row of a spreadsheet or one page of a document is fine. What matters is that you write it before launch and don't change it afterward.
| Item | What to write | Example entry |
|---|---|---|
| Target page | The URL of the page to test and the visitors to include | Pricing page. All visitors on all devices |
| Observed fact | The data your hypothesis is based on | On mobile, only about 40% of people reach the pricing table |
| Hypothesis | What you'll change, why, and what will change | If the pricing table moves higher on the page, more people will see the prices and sign-ups will increase |
| Change | What changes in B (limit it to one thing) | Move the pricing table to just below the first screen |
| Primary metric | The one number that decides the winner | Share of people who reach the sign-up complete page |
| Secondary metrics | Numbers to look at to explore the reasons | Reach rate of the pricing table, click rate of the sign-up button |
| Guardrail metrics | Numbers that would be a problem if they dropped | Cancellation inquiries, page load speed |
| Current conversion rate | Results over roughly the past 4 weeks | 2.5% |
| Difference to detect | The smallest difference you care about; you're fine missing anything smaller | +20% relative (2.5% → 3.0%) |
| Decision criteria | Significance level and statistical power | 5% significance level, 80% power, two-sided test |
| Required sample size | Per variation | About 16,800 visitors |
| Duration | Start date and end date | 6 weeks (start on Monday, end on Sunday) |
| Stop conditions | Cases where you stop even before the period ends | Broken layout, a sign-up malfunction, a sudden worsening of a guardrail metric |
Narrow it down to one primary metric
Use only one metric to decide the winner. If you decide that B wins when any of "sign-up rate," "click rate," or "time on page" improves, the chance that one of them happens to look better by chance rises with the number of things you compare (this is explained in more detail in "When You Compare 3 or More Variations or Multiple Metrics" later).
Choose a primary metric as close as possible to a business result (a completed purchase, sign-up, or request for materials). However, if the number of conversions is so small that judging would take months, you can instead use an action one step earlier (showing the sign-up form, adding to cart) as the primary metric. In that case, note on the sheet that an increase in the earlier action doesn't necessarily mean the final result will increase.
Decide your guardrail metrics in advance
Separately from the primary metric, decide on numbers that must not drop. For example, making a sign-up button more prominent may increase sign-ups, but it can also lead more people to sign up without understanding the offer, and cancellations and inquiries rise as well. Guardrail metrics are used not to decide the winner but to catch situations where "it looks like a win, but you shouldn't adopt it."
Build hypotheses from data
An idea like "somehow, this one seems better" leads nowhere whether it wins or loses. From observed facts (analytics numbers, or behavior you saw in a heatmap), write in a sentence "what's the cause, and what changes if you change what." The steps for building a hypothesis from a heatmap are covered in detail in How to Read a Heatmap and Analyze It.
2. Calculate the Required Sample Size and Duration
The "required sample size" and "duration" on the design sheet are decided by calculation. The required sample size is determined mainly by two things: your current conversion rate and the difference you want to detect.
Get a rough idea from a lookup table
The following table gives approximate visitors needed per variation (calculated with a standard formula for comparing two proportions, using a two-sided test, a 5% significance level, and 80% power).
| Current conversion rate | Detect +10% | Detect +20% | Detect +30% | Detect +50% |
|---|---|---|---|---|
| 1% | about 163,000 visitors | about 42,700 visitors | about 19,800 visitors | about 7,800 visitors |
| 2% | about 80,700 visitors | about 21,100 visitors | about 9,800 visitors | about 3,800 visitors |
| 5% | about 31,200 visitors | about 8,200 visitors | about 3,800 visitors | about 1,500 visitors |
| 10% | about 14,800 visitors | about 3,800 visitors | about 1,800 visitors | about 700 visitors |
"+10%" in the table is a relative improvement. For a page with a 2% conversion rate, it means the difference between 2.0% and 2.2%.
What the table shows is that detecting a small difference takes more visitors than you'd expect. If you halve the difference you want to find, the required sample size becomes roughly 4 times larger. To confirm a 10% improvement on a page with a 2% conversion rate, you need more than 160,000 visitors across A and B combined.
Calculate with your own numbers
For numbers not in the lookup table, you can calculate in a spreadsheet (Google Sheets or Excel). Let p1 be your current conversion rate and p2 the conversion rate you expect after the change. The required sample size per variation is then given by the following formula (for a 5% significance level and 80% power).
=((1.96*SQRT(2*((p1+p2)/2)*(1-(p1+p2)/2)) + 0.84*SQRT(p1*(1-p1)+p2*(1-p2)))^2) / (p2-p1)^2
These formulas work in Google Sheets and Excel.
For example, entering 0.025 for p1 and 0.03 for p2 gives about 16,800 visitors.
For a mental estimate, you can also use the approximation "16 × current conversion rate × (1 − current conversion rate) ÷ difference squared." With a 2.5% conversion rate and a difference of 0.5 percentage points, 16 × 0.025 × 0.975 ÷ 0.005² = 15,600 visitors, which comes out a little lower than the exact calculation (about 16,800 visitors). A/B testing tools and publicly available sample size calculators perform the same calculation just by entering the numbers.
Calculate the duration
Calculate the duration by dividing the required sample size by the number of visitors who reach each variation per day.
Duration (days) = required sample size per variation ÷ (daily visitors to the target page × share of traffic included in the test ÷ number of variations)
Let's calculate using the design sheet example. Suppose the pricing page gets 800 visitors a day, all of them are included in the test, and they're split evenly between A and B. 400 visitors a day reach each variation, so 16,800 ÷ 400 = 42 days, exactly 6 weeks.
Don't use the calculated result as is; round the duration up to whole weeks (multiples of 7 days). Visitor mix and intent change by day of the week, so ending partway through a week lets a day-of-week bias get mixed into the results. Also, even if the calculation says a few days is enough, it's common to run for at least 1 to 2 weeks to avoid the temporary reaction caused by the novelty of a change.
When the calculated duration is too long
If the calculated duration is well over 2 months, review the design instead of launching as is. The longer the period, the more disturbances creep in: seasons and ad conditions change, and cookies get deleted so the same person sees a different variation.
- Increase the difference you want to detect: Choose an idea that changes the structure or the pitch significantly, rather than a small wording change
- Run it on a high-traffic page: Pick a page that serves as an entry point to your site, or the landing page for your ads
- Use a metric with a higher conversion rate: Use showing the sign-up form as the primary metric instead of sign-up completion
- Increase the share of traffic in the test: If you were including only some visitors, include everyone
If none of these is feasible, you'll use your time better by confirming the direction of improvement through heatmaps or user interviews instead of an A/B test.
3. After Launch, What to Check First
One to three days after launch, before you look at the numbers in the results (which version is ahead), check that the test is running correctly.
Is the traffic split skewed?
If you set the test to serve A and B half and half, the number of visitors to each should be nearly the same. A large deviation is called Sample Ratio Mismatch (SRM). A skewed ratio often indicates that some visitors are missing from the records in one of the variations, and results in that state can't be trusted.
You can check in a spreadsheet whether the deviation is within the range of chance. For a half-and-half setup, enter A's visitor count in cell A1 and B's in B1, and enter =(A1+B1)/2 (the expected count) in both A2 and B2. Then enter the following formula to get a p-value.
=CHISQ.TEST(A1:B1,A2:B2)
For example, with 10,000 visitors for A and 10,100 for B, the p-value is about 0.48, which is within the range of chance. With 10,000 for A and 10,400 for B, the p-value is about 0.005. Even a gap this size is treated as a skew that is unlikely to happen by chance. As a general rule, if this p-value falls below 0.01, investigate the cause before you read the results.
Common causes of a skewed ratio are as follows.
- Only page B is slow to display, and people who left before it appeared aren't recorded
- The tracking tag fails to load on B, or is recorded twice
- Variations are switched by a redirect (forwarding to a different URL), and some people leave mid-redirect
- The traffic split was changed partway through the test
Are conversions recorded correctly?
Display both A and B yourself, perform the action that counts as a conversion (clicking a button, or viewing the completion page), and confirm that one conversion is recorded for each. If you changed the button's position or wording in B, pay particular attention to whether the conversion condition (which button's clicks to count) applies to B as well.
Verify the setup with an A/A test
When you use an A/B testing tool for the first time, or after you change how measurement works, you can also verify the setup with an A/A test, which splits the exact same page into two variations. Because the pages are identical, there shouldn't be any difference. If the traffic split is skewed, or large differences show up almost every time, you know there's a problem with the tool's settings or the measurement.
4. Wait Until the Period Ends: Why You Must Not Stop Midway
Opening the results screen while the test is running is not a problem in itself. The problem is looking at results midway and stopping at that point if a significant difference has appeared.
The numbers in the results swing up and down as data accumulates. Even for a change with no effect at all, they can temporarily enter the "significant" range partway through the swings. If you repeat "stop if significant" each time you look, you get more chances to catch such temporary swings.
Let's check by calculation how much this increases. In a state with exactly the same effect for A and B (that is, no real difference), at a page with a 3% conversion rate, we simulated a 4-week test with 500 visitors per variation per day, repeating it 20,000 times on a computer (5% significance level, two-sided test).
| How you look at results | Share that came out "significant" and stopped |
|---|---|
| Judge only once, after 4 weeks | about 4.8% |
| Look once a week (4 times) and stop if significant | about 12.4% |
| Look every day (28 times) and stop if significant | about 27.0% |
If you judge only once at the end, the share that wrongly says "there's a difference" stays around the 5% significance level you set. If you look daily and stop, that rises to about 27%; in other words, more than 1 time in 4, a change with no effect gets judged a "win."
This problem happens not only with tools that judge by p-value but also with tools that judge by "probability of winning." If you stop at the moment the probability happens to be high, you pick up chance in the same way.
If you really want to judge midway, you need to decide before you start on a judging method designed on the assumption that you'll look midway (a method called sequential testing). Check that the tool you use supports it before you adopt it.
What not to do while the test is running
Besides stopping midway, doing the following while the test is running makes the results unreadable.
- Changing the contents of a variation: If you fix B's wording midway, the first and second halves become different tests
- Changing the traffic split: If you change from 50 to 80 midway, differences in visitors over time get mixed into the results
- Starting a major initiative on the same page: If a large ad campaign or sale starts at the same time, its effect may be unevenly distributed across variations
If you need to make a change, end that test and start over as a new test.
5. Judge: Verify Statistical Significance Yourself
When the period you decided on ends, you judge. Here we show the steps of the most common test for comparing the conversion rates of two variations, using a worked example. Even if your tool judges automatically, calculating by hand once makes the numbers on the screen easier to understand.
Worked example: a test that finished as designed
Suppose that in the design sheet example, the 6-week test is over and the results are as follows.
| Visitors | Conversions | Conversion rate | |
|---|---|---|---|
| A (original page) | 16,800 visitors | 420 | 2.50% |
| B (pricing table moved up) | 16,800 visitors | 504 | 3.00% |
The difference is 0.5 percentage points, or +20% in relative terms. We check in four steps whether this difference can be explained by chance.
Calculate the overall conversion rate
Calculate the conversion rate for A and B combined. (420 + 504) ÷ (16,800 + 16,800) = 2.75%. This is the conversion rate assuming "there's no difference between A and B."
Calculate the spread of the difference (standard error)
Assuming there is no difference, calculate how much the difference between the two conversion rates would vary. √(0.0275 × 0.9725 × (1/16,800 + 1/16,800)) ≒ 0.00178, which is about 0.18 percentage points.
Calculate how many times the spread the difference is
Divide the observed difference by the spread. 0.005 ÷ 0.00178 ≒ 2.80. This value is called the z-score.
Calculate the p-value
Get the p-value from the z-score. In a spreadsheet, =2*(1-NORM.S.DIST(2.80,TRUE)) gives about 0.005. It's below the 5% significance level (0.05), so you conclude that "there is a statistically significant difference."
To calculate it in a spreadsheet in one go, let n1 and x1 be A's visitors and conversions and n2 and x2 be B's. The following formula gives the p-value.
=2*(1-NORM.S.DIST(ABS((x2/n2-x1/n1)/SQRT(((x1+x2)/(n1+n2))*(1-(x1+x2)/(n1+n2))*(1/n1+1/n2))),TRUE))
Look at the range of the difference (confidence interval)
A p-value tells you "whether you can say there's a difference," but not "how large the difference is." So look at the confidence interval as well. A confidence interval is a range within which the true difference is likely to fall.
The 95% confidence interval for the difference in conversion rates is calculated with the following formula.
Difference ± 1.96 × √( A's conversion rate × (1 − A's conversion rate) ÷ A's visitors + B's conversion rate × (1 − B's conversion rate) ÷ B's visitors )
In the worked example, it's about +0.15 percentage points to +0.85 percentage points. Converted to relative improvement, that's about +6% to about +34%. The entire interval is on the positive side, so it's almost certain that B is better. However, the size of the improvement has a range: "it might be around 6%, or it might be around 34%." The observed +20% is just the value in the middle of that range.
Example where no significant difference appeared
What if B had 454 conversions (2.70%) over the same period? Calculating with the same steps, the p-value is about 0.24, and the 95% confidence interval for the difference is about −0.14 percentage points to +0.54 percentage points.
The interval crosses zero, so you can't say "B is better." But that doesn't mean "A and B are the same" either. The upper end of the interval reaches +0.54 percentage points (about +22% in relative terms), so both "B may be quite a bit better" and "B may be slightly worse" remain possible. In other words, the result is that this data can't settle it.
How to read the "probability of winning"
Some tools show numbers such as "probability that B is better than A" or "probability of being the best" instead of a p-value. These are calculated with an approach called Bayesian statistics, and they represent "the probability, given the data so far, that B's true conversion rate is higher than A's."
Calculating the worked example numbers with this approach gives about 99.8% for the example with a significant difference (504 conversions) and about 88% for the example without one (454 conversions). 88% may sound like "B is almost surely the winner," but it means that more than 1 time in 10, B is actually worse, which is a shaky number on which to base an adoption decision. Many tools set a threshold such as 95% and present a candidate winner once it is exceeded.
The p-value and the "probability of winning" differ in both their assumptions and their meaning. There is no correspondence such as "a p-value of 0.05 means a 95% probability of winning." With either approach, the principle stays the same: decide the duration and sample size first, and judge once at the end.
6. Decide What to Do Next for Each Result
Don't decide "adopt or reject" from the presence or absence of a significant difference alone. Combine the range of the difference with the guardrail metrics, and think of the outcome as one of the following four.
| Result | Range of the difference (confidence interval) | Decision |
|---|---|---|
| B is significantly better | Entirely on the positive side | Adopt it if the guardrail metrics show no problem. Estimate the size of the improvement from the lower end of the interval |
| B is significantly worse | Entirely on the negative side | Keep A. Record which part of the hypothesis was wrong |
| No significant difference, wide range | Crosses zero; a large positive or negative effect is possible | Not enough data. Redo it with a bigger change, or redesign the duration |
| No significant difference, narrow range | Stays close to zero | Any difference is small. Either is fine, so choose whichever is easier to build and operate |
When you shouldn't adopt it despite a significant difference
Even if a significant difference appears, don't adopt it right away in cases like the following.
- A guardrail metric has dropped: Sign-ups increased, but cancellations and inquiries also increased
- The difference is too small to justify the effort of the change: With very large amounts of data, even a tiny difference becomes significant
- There's a traffic split skew: The check in the previous section found a skewed ratio
- The result comes from an unusual period: It overlapped with a sale or a major ad campaign, and the visitor mix differed from usual
A test with no significant difference is not a failure
You can learn from a test with no significant difference, too. If you learn that "the position of the pricing table doesn't affect sign-ups much with a change of this size," you can move on to a bigger change next time, or to a hypothesis about a different place. Looking at whether secondary metrics (such as the reach rate of the pricing table) moved lets you tell apart "the change produced the intended behavior but it didn't lead to conversions" from "the behavior didn't change at all."
When You Compare 3 or More Variations or Multiple Metrics
If you compare three variations (A, B, and C) at once, or judge winners and losers by several metrics besides the primary metric, the number of comparisons goes up. The more comparisons you make, the higher the chance that one of them happens to be "significant" by chance.
At a 5% significance level, when you make several comparisons in which there is really no difference in any of them, the probability that at least one is "significant" by chance is as follows.
| Number of comparisons | Probability that at least one is "significant" by chance |
|---|---|
| 1 | 5% |
| 3 | about 14% |
| 10 | about 40% |
There are three countermeasures.
- Decide the winner by one primary metric: Treat the other metrics only as reference for exploring reasons
- Limit the number of variations: Adding variations also reduces the visitors per variation and lengthens the duration
- Use a stricter significance level when there are many variations: A simple method is to divide the significance level by the number of comparisons (the Bonferroni correction). If you compare 3 variations against A, use 5% ÷ 3 ≒ 1.7% as the criterion
When you break results down by device or traffic source
Breaking results down by mobile versus desktop, or by ads versus search, is useful for exploring reasons. But be careful about deciding the winner from the broken-down results, because the more you split, the more comparisons you make and the fewer visitors fall in each segment.
A result like "there was no difference overall, but looking at mobile only, B was significantly better" is likely to be due to chance. If you want to confirm that it really works on mobile, start over from the design as a new test targeting mobile only. This doesn't apply if you decided before you started to judge mobile and desktop separately.
7. Record It and Connect to the Next Test
When the test ends, add the results and what you learned to the design sheet and keep it all in one place.
- Results: Visitors, conversions, and conversion rate for each variation, the p-value (or probability of winning), and the confidence interval of the difference
- Decision: Whether you chose adopt, pass, or redo, and why
- Check records: The traffic split, and what happened during the period (ad changes, outages, and so on)
- Lessons: Which parts of the hypothesis were right and which were wrong, and what to try next
As records accumulate, you develop a sense of "what kinds of changes make how much difference on this site." With that sense, you can set a realistic difference to detect in your next test, and your estimates of the required sample size and duration become more accurate. It's important to keep not only the tests that won but also the tests that lost and the ones that were inconclusive, in the same way.
Finally, here is the test flow as a checklist.
Design
I wrote the design sheet before launch. There is one primary metric. I also decided the guardrail metrics and stop conditions.
Calculate sample size and duration
I calculated the required sample size per variation from the current conversion rate and the difference to detect. I rounded the duration up to whole weeks and confirmed it doesn't go well past 2 months.
Launch and check
The traffic split isn't skewed. I confirmed myself that conversions are recorded correctly in both A and B.
Wait until the period ends
Even when I looked at results midway, I didn't stop unless a stop condition was met. I didn't change the contents or the split during the test.
Judge
I looked at the p-value (or probability of winning) and the confidence interval of the difference. There is no problem with the guardrail metrics.
Record
I saved the results, the decision, what happened during the period, and what I learned. I decided the next hypothesis.
If You Run A/B Tests with HeatMapX
This section introduces the features available when you practice the steps in this article with HeatMapX, the product we provide (as of November 2026).
- How to create variations: You can choose between two methods: replacing headings, text, or elements on the same page, or splitting traffic to a different URL
- How to define conversions: You can choose from three types: a click on a specific element, a view of a specific page, or scrolling the page to a certain percentage
- Traffic allocation: You can set the share of visitors included in the test and the allocation to each variation. The thinking behind this is explained in Traffic Allocation vs. A/B Split
- Display of results: It shows visits, conversions, and conversion rate for each variation, along with the "probability of beating the original." Judging uses the "probability of winning" approach: when every variation has been shown to at least 100 visitors and the probability exceeds 95%, it's shown as a candidate winner. Until a variation reaches 100 visitors, it shows an estimate of how many more visitors and days are needed
- Combining with heatmaps: You can also collect heatmaps with the same tracking tag, so you can go from building a hypothesis to confirming the reason for a result in one tool
- Analysis with AI: You can connect it to an AI such as Claude and have it read the data from test results. How to connect is explained in How to Connect HeatMapX to AI via MCP
The number of tests you can run at the same time depends on your plan (the free plan allows one). You can check what each plan includes on the pricing page.
Frequently Asked Questions (FAQ)
How many visitors do I need before I can make a judgment in an A/B test?
It depends on your current conversion rate and the size of the difference you want to detect, so there is no single number. To detect a 20% improvement on a page with a 2.5% conversion rate, about 16,800 visitors per variation is the guideline. Use the lookup table in this article or the spreadsheet formula to calculate with your own page's numbers.
If a significant difference appears, can I stop the test right away?
No. Wait until the period you decided on before starting has ended. If you stop as soon as a significant difference appears midway, the chance that a change with no effect is judged a "win" rises greatly. The only time you may stop midway is when you hit a stop condition you set in advance, such as a broken layout or a malfunction.
What should I do if the p-value is slightly above 0.05?
Don't conclude "there is a significant difference." But don't conclude "there is no difference" either; look at the confidence interval of the difference. If the interval extends to a large positive value, you may not have had enough data. Rather than extending the period, the safe approach is to redo the calculation and redesign it as a new test.
Does the significance level have to be 5%?
5% is a value commonly used by convention, not a rule. For changes where a mistaken adoption would be costly (such as price display or the sign-up procedure), you may make it stricter, such as 1%. Whichever value you use, it's important to decide it before you start and not change it afterward.
Can I run A/B tests on a site with little traffic?
You can, but small differences become hard to detect. You can reduce the sample size you need by focusing on big changes, running the test on a high-traffic page, or using an action before the conversion as the primary metric. If the calculated duration is well over 2 months, you'll be more efficient confirming the direction of improvement through heatmaps or interviews.
Do I need to run an A/A test every time?
Not every time. Running one when you use a tool for the first time, after you change how measurement works, or when there's something unnatural in the results (such as a skewed traffic split) lets you check whether there's a problem with the setup.
Summary: Decide the Rules First, and Keep to Them to the End
What matters in how you run an A/B test is not the fine detail of the calculations but deciding your judging rules before launch and keeping to them until the end.
- Write one design sheet and narrow it down to one primary metric
- Calculate the required sample size and duration from the current conversion rate and the difference you want to detect
- After launch, check the traffic split and conversion records before you look at results
- Even if you look at results midway, don't stop until the period you decided on ends
- Look at the p-value and the range of the difference together, and decide to adopt, pass, or redo
- Win or lose, record the results and what you learned, and connect them to the next hypothesis
If you follow these steps, you can trust the conclusion of each test, and the more tests you run, the more knowledge about your site accumulates. To start, write one design sheet for the next change you want to try.