A/B Testing
Pitfalls
Learn to identify and avoid the most common mistakes in A/B testing: peeking at results, multiple comparisons, and selection bias.
What Is A/B Testing?
An A/B test (also called a randomized controlled experiment) splits users randomly into two groups: a control group that sees the current version and a treatment group that sees a new variant. We then measure a key metric (conversion rate, revenue, click-through rate) and use statistical inference to decide whether the difference is real.
The Hypothesis Testing Framework
Why Pitfalls Matter
When we violate the assumptions behind hypothesis testing, we inflate the false positive rate: we conclude there is a real effect when there isn't one. Companies then ship changes that don't actually help, or worse, hurt the user experience.
Pitfall 1: Peeking at Results
Peeking (also called repeated significance testing) means checking your p-value before the pre-planned sample size is reached and stopping the test early if it looks significant. This dramatically inflates the false positive rate because you are giving yourself multiple chances to find significance by chance.
Why Peeking Inflates Error Rates
Pitfall 2: Multiple Comparisons
When you test multiple metrics, multiple variants, or multiple user segments in the same experiment, each test is an independent chance to find a false positive. This is the multiple comparisons problem (also called the family-wise error rate inflation).
Correcting for Multiple Comparisons
Pitfall 3: Selection Bias
Selection bias occurs when the groups in your A/B test differ systematically in ways other than the treatment. This violates the fundamental assumption of random assignment and can produce misleading results.
Random vs. Biased Assignment
Type I vs. Type II Errors
| Type I (False Positive) | Type II (False Negative) | |
|---|---|---|
| Definition | Rejecting \( H_0 \) when it is actually true | Failing to reject \( H_0 \) when it is actually false |
| Probability | \( \alpha \) (significance level) | \( \beta \) |
| Consequence | Ship a change that doesn't work | Miss a change that would have helped |
| Pitfall link | Peeking, multiple comparisons | Underpowered tests (too small \( n \)) |
| Controlled by | Setting \( \alpha \) (e.g., 0.05) | Increasing sample size or effect size |
The Statistical Significance Rule
How to Run a Valid A/B Test
Example 1: Simple A/B Test
A company tests a new checkout button color. They plan for \( n = 10{,}000 \) users per group, \( \alpha = 0.05 \), and one primary metric (conversion rate). After collecting the full sample:
(\( \frac{320}{10{,}000} \))
(\( \frac{380}{10{,}000} \))
Example 2: The Peeking Trap
Same experiment, but the analyst checks the dashboard every day for 14 days. On day 4, the p-value briefly dips to \( 0.03 \), so they stop the test and declare victory.
Example 3: Multiple Metrics Trap
A team tests a new homepage design and measures 8 metrics: page views, time on site, bounce rate, sign-ups, purchases, click-through rate, scroll depth, and shares. Only sign-ups shows \( p = 0.04 \). They celebrate and announce the redesign "significantly boosts sign-ups."
Common Mistakes to Avoid
Summary: Pitfalls at a Glance
| Pitfall | What Goes Wrong | How to Fix |
|---|---|---|
| Peeking | Multiple looks inflate false positive rate beyond \( \alpha \) | Wait for full \( n \) or use sequential testing |
| Multiple Comparisons | Testing many metrics/variants multiplies chance of false discovery | Bonferroni, Holm, or FDR correction |
| Selection Bias | Non-random groups confound treatment with other variables | Random assignment + A/A validation |
| Low Power | Too few users to detect real effects (high Type II error) | Power analysis before test; increase \( n \) |
Question 1 of 5
An analyst checks the p-value of an A/B test every day for 10 days and stops the test on day 3 when \( p = 0.04 \). What pitfall is this an example of?
Question 2 of 5
A team tests 20 different metrics in one A/B test. Using the Bonferroni correction with \( \alpha = 0.05 \), what p-value threshold should each metric use?
Question 3 of 5
A company assigns all mobile users to variant A and all desktop users to variant B, then compares conversion rates. What is the primary concern?
Question 4 of 5
If you run 10 independent A/B tests, each at \( \alpha = 0.05 \), what is the approximate probability that at least one produces a false positive?
Question 5 of 5
Which of the following is the best practice to avoid inflating the false positive rate when you need to monitor an A/B test before the planned end date?