Track 11 · Experiments and A/B Testing · Lesson 1 of 14

Why experiment?

Explain why randomly assigning users to versions lets you read a difference in outcomes as the causal effect of the change, and why observational comparisons usually cannot.

25 minIntermediate6 graded exercisesFree

A product team notices that shoppers who use the new “save for later” button buy three times as often as those who do not. Should the company make the button bigger, or are keen shoppers simply the ones who click it? Only an experiment can tell the two stories apart.

Product and business teams constantly ask causal questions: Does the redesigned checkout make people buy more? Does a lower price bring in enough extra subscribers to pay for itself? A causal question is about what would happen if we changed something, not just about which things go together.

Data collected by watching what people do anyway — observational data — answers a different question: who tends to do what. The two are easily confused.

GroupVisitorsPurchasersConversion rate
Used “save for later”2,0001809.0%
Did not use it18,0005403.0%
An observational comparison (hypothetical figures for one month of visitors)

Users of the button convert at 9.0% against 3.0% — 3.0 times as often. But the users chose to click. People who were already planning to buy, who visit often, or who have full baskets are far more likely to save items. Their high conversion rate could be entirely due to who they are, not to the button. This is self-selection, a form of confounding: a third factor (purchase intent) drives both the behaviour and the outcome.

effect=E⁡[Y(1)]−E⁡[Y(0)]effect^=yˉB−yˉA\text{effect} = \E[Y(1)] - \E[Y(0)] \qquad \widehat{\text{effect}} = \bar{y}_{B} - \bar{y}_{A}
The average causal effect, and how a randomised experiment estimates it
Y(1), Y(0)Y(1),\ Y(0)
a user's outcome (e.g. 1 = bought) with the change and without it — the two potential outcomes. We only ever see one of them for each user.
E⁡[⋅]\E[\cdot]
the average over all users
yˉB, yˉA\bar{y}_{B},\ \bar{y}_{A}
the observed average outcome in the treatment group B and in the control group A

We can never see the same user both with and without the change. A randomised controlled experiment (an A/B test in product work) solves this by letting a coin decide who gets which version. Because the coin knows nothing about the user, the two groups are alike on average in everything — intent, device, mood, wealth, things we have measured and things we have not. Any difference in outcomes beyond chance variation can then be attributed to the change itself.

Worked example

Did the coin balance the groups?

In the (synthetic) checkout_ab experiment, 16 000 new visitors were randomly assigned to the current checkout (A) or a redesign (B). Device and location were recorded before assignment could affect anything. Are they balanced?

  1. Device. Mobile users make up 62.1% of group A and 61.4% of group B.

  2. Location. Domestic visitors are 69.8% of A and 69.9% of B.

  3. Read it. The shares differ by well under one percentage point — the size of difference chance alone produces with 8 000 users per group. A balance table like this is a check that the randomisation was carried out correctly (no bug sent, say, more desktop users to B). It cannot show that unmeasured factors are balanced — that guarantee comes from the coin itself, which balances measured and unmeasured factors alike on average.

The groups are comparable on pre-treatment characteristics, so a difference in conversion can be read causally (allowing for chance).

Dataset

Checkout redesign A/B test

16,000 rows · one row = one user in the experiment · synthetic data

UserTest day (day)Signup dateVariantDeviceCountry segmentConvertedRevenue (SAR)Checkout load time (ms)
U0000112024-05-05Bmobiledomestic001781
U0000212024-05-05Bmobiledomestic001842
U0000312024-05-05Bmobiledomestic001197
U0000412024-05-05Adesktopgcc001035
U0000512024-05-05Btabletgcc001774
U0000612024-05-05Adesktopdomestic001609

One row per user: assigned variant, device, location segment, signup day, whether they bought, revenue and checkout page-load time.

Quick check

Why does random assignment allow a causal reading of the difference between groups?

The life of an experiment (what this track covers)

  1. Write the hypothesis and the decision it will inform.
  2. Choose the unit of randomisation and the metrics (primary, secondary, guardrails).
  3. Plan the sample size and duration from the minimum effect worth detecting.
  4. Randomise, run, and check the plumbing (A/A tests, sample ratio mismatch).
  5. Analyse once, at the planned end: difference, confidence interval, test.
  6. Decide, weighing the uncertainty, the guardrails and the business costs.

Exercises

The lesson is complete when every exercise is answered correctly. Hints are free; viewing a worked solution before solving means the exercise won't count towards mastery.

0 of 6 exercises correct (not saved — sign in to keep your progress)

Exercise 1 · Interpretation, difficulty 1 of 3

Why the button looks magical

Not started

Users of the “save for later” button converted at 9.0%, non-users at 3.0%. What is the most important reason this comparison cannot tell us the effect of the button?

Choose one

Exercise 2 · Practice, difficulty 1 of 3

Experiment or observation?

Not started

Classify each study as a randomised experiment or an observational study.

Visitors are assigned by a hash of their user id to see the old or the new search page
Comparing the spending of customers who joined the loyalty programme with those who did not
Comparing conversion in the month before and the month after a site redesign
Half of the stores, chosen by lottery, get a new shelf layout
Regions where the sales team chose to pilot a discount compared with the other regions

Exercise 3 · Application, difficulty 2 of 3

Check the balance

Not started

In checkout_ab, randomisation should balance pre-treatment characteristics. Calculate the percentage of users on desktop within variant A and within variant B (2 decimal places).

Data: checkout_ab · Open in the lab to explore and calculate.

Exercise 4 · Challenge, difficulty 3 of 3

A feature that does nothing

Not started

A wish-list feature was used by some visitors but not others. Visitors fall into two types:

TypeUsed the featureDid notConversion (both)
Engaged800170010%
Casual50065001%

Within each type, users and non-users convert at exactly the same rate. Calculate the overall conversion rate of feature users and of non-users (%, 2 decimals), and the naive difference users − non-users (percentage points, 2 decimals).

Exercise 5 · Practice, difficulty 1 of 3

Order the experiment

Not started

Put the steps of a well-run A/B test in order.

Put the steps in order (use the arrows)

  1. 1Randomise users and run the test for the planned duration
  2. 2Make and document the decision
  3. 3State the hypothesis and the decision the test will inform
  4. 4Calculate the sample size from the minimum effect worth detecting
  5. 5Check assignment counts for sample ratio mismatch
  6. 6Choose the randomisation unit and the primary, secondary and guardrail metrics
  7. 7Analyse the primary metric once, with a confidence interval

Exercise 6 · Interpretation, difficulty 2 of 3

Answer the product manager

Not started

A product manager writes: “Save-for-later users convert at 9.0% versus 3.0%. Let's make the button twice as big — it clearly drives purchases.” In two to four sentences, explain why the data do not show that, and propose how to find out.

0 words

What you can now do

  • Distinguish a causal question from an association
  • Explain self-selection and confounding in product data
  • Explain why random assignment supports causal conclusions
  • Check covariate balance in a randomised experiment