← Statistics

Inference & experiments

A/B Testing

A/B testing is a controlled experiment that compares two versions of a website, app or marketing message. The versions differ in a single feature, so any difference in how users behave can be traced back to that one change.

In a business, A/B testing helps stakeholders optimize websites and apps to improve marketing results, revenue or customer experience. Instead of relying on opinions, a team tests a change on a share of its users, for example a new checkout button, a different headline or a redesigned onboarding flow, and decides based on evidence.

The results are judged with metrics such as average revenue per user, session duration, click rate and conversion rate.

Why do we need A/B testing?

Observed differences between two versions may simply be due to random chance. Statistical inference helps determine whether a difference is likely to be genuine before a decision is made.

Imagine an online shop changes its checkout button to green. In the following week, the conversion rate rises from 5.0% to 5.6%. Did the button cause this? Not necessarily. Conversion rates move up and down from week to week by chance, and that week might also have included a sale or a holiday.

The two problems A/B testing is exceptionally good at solving are:

How to design an A/B test

This is a common interview question. A clean answer walks through five steps: variables, hypothesis, metrics, assigning users to groups, and analysis of the results. The running example below is a messaging app that wants to test group video calling.

Step 1: Define your variables

Start by naming the cause you want to test and the effect you want to measure. This keeps the experiment focused on one relationship.

A more complex test might compare several versions of the feature, or several settings of the same feature. The logic stays the same: you change the independent variable and watch what happens to the dependent variable.

Step 2: Formulate your hypothesis

A good experiment starts with a clear, testable hypothesis: a statement that connects the feature to an expected outcome. A strong hypothesis has three parts:

For the statistical test later on, the hypothesis is written as a pair of competing statements:

The test then asks whether the data give enough evidence to reject the null hypothesis.

Step 3: Choose metrics

The goal is not to track activity, but to measure whether the feature is delivering real value.

Three cards: a primary metric that shows whether the feature delivered value, supporting metrics that explain why it changed, and guardrail metrics that check nothing else got worse
Chart 1 The three kinds of metrics and the question each one answers (examples).

Before running an A/B test, ask

  1. What decision am I trying to make?
  2. What user behavior represents success?
  3. Can I measure it reliably?
  4. Will the experiment likely affect this metric?
  5. Are there guardrail metrics to ensure I'm not causing unintended harm?

Step 4: Assign users to treatment and control groups

An A/B test is a controlled experiment. The treatment is the change being tested, and users are split into two groups:

The difference in the metric between the two groups is the measured effect of the treatment. For example, if the treatment group averages 4.4 calls per user and the control group 4.0, the feature added 0.4 calls per user. This only works if exposure to the feature is the only meaningful difference between the groups. If the treatment group happened to contain mostly power users, you could not tell whether the feature or the user mix caused the gap.

Eligible users are randomly assigned to group A, the control with 1:1 video calling, or group B, the treatment with group video calling
Chart 2 Random assignment: every eligible user has the same chance of landing in either group.

An important decision is who to include in the experiment.

Key principle: randomization

Randomization is important because it:

Why it matters

Without randomization, it's difficult to know whether the change caused the result or whether some other factor did. Such a factor is called a confounder, and confounders can lead to incorrect conclusions about cause and effect.

Bar chart: when users choose their group, 70 percent of the treatment group are heavy users versus 25 percent of control; with random assignment the shares are about 45 and 47 percent
Chart 3 Illustrative data. If heavy users pick the new feature themselves, the groups differ before the test starts. Random assignment evens them out.

Two ways to randomize

A nuisance factor is something that affects the outcome but is not what you are testing. Suppose mobile users make far fewer calls than desktop users. With a small sample, pure randomization could by chance put more desktop users in one group and distort the comparison. To prevent this, block by device: split users into mobile and desktop, then randomize within each block. If a difference appears inside a block, you can be more confident that the feature caused it and not the device.

Also think about how long to run the experiment. The duration should be long enough to capture typical user behavior, but not so long that it delays decision-making.

Pro tip

In interviews, clearly state who is in control vs treatment, how users are assigned, and what you are comparing. Also consider network effects. For example, if a group of friends interacts frequently, assigning them to different groups can introduce bias. Where possible, group related users together to minimize interference.

Checklist for reducing bias

Before launching an A/B test, ask yourself:

Step 5: Analyse results and draw conclusions

The question to ask: "Did B perform better because of our change, is the improvement large enough to matter, and did it avoid causing other problems?"

#CheckWhat to do
1Experiment validityMake sure the experiment was conducted correctly. Check randomization, and look for problems such as missing data, users who saw both versions, or unequal exposure.
2Effect sizeCalculate the key metrics and the effect, as an absolute and a relative improvement (see below).
3Statistical significanceAsk whether this difference could have happened by random chance, using the p-value.
4Confidence intervalLook at the range of plausible effects.
5Supporting and guardrail metricsThe change may not be a success if it created other problems.
6SegmentsCheck important user groups carefully to see whether the new design helps some users but harms others.
7DecisionTreatment wins, no clear difference, or treatment loses.

Effect size: absolute vs relative

Bars showing a conversion rate of 5.0 percent for control and 5.6 percent for treatment, an absolute difference of 0.6 percentage points and a relative improvement of 12 percent
Chart 4 Illustrative numbers: the same result as an absolute and as a relative improvement.

Statistical significance and the p-value

If there were actually no difference between A and B, how likely is it to observe a difference this large? If that is unlikely (commonly p < 0.05), the difference is considered statistically significant.

Confidence intervals

A confidence interval shows the range of plausible effects. It tells us, for example: based on this experiment, the true improvement is plausibly between 0.40% and 0.80%.

Three confidence intervals: one entirely above zero where the treatment wins, one that crosses zero meaning no clear difference, and one entirely below zero where the treatment loses
Chart 5 How the confidence interval relates to the decision (illustrative).

Key takeaways

  • Randomize. Random assignment makes the groups comparable, so a difference can be attributed to the change and not to a confounder.
  • Define success before you start. Choose one primary metric, add supporting metrics for context and guardrail metrics to catch harm.
  • Check validity first. Verify the split, missing data and unequal exposure before looking at results.
  • Size matters, not just significance. Report the absolute and relative effect, not only the p-value.
  • Use the confidence interval. It shows the range of plausible effects and makes the decision clear: treatment wins, no clear difference, or treatment loses.
  • Look at the whole picture. Guardrail metrics and key segments can turn a win into a problem.