What exactly are you measuring
Before the statistics, a plainer question: what counts as success, for whom, and what must not get worse along the way. Most bad decisions are made here, long before any p-value.
Ask three people on a team what an experiment is trying to improve and you will often get three answers: more clicks, more bookings, happier customers. All three sound reasonable. They can move in different directions, and a test that has not chosen between them in advance will find a winner among them afterwards. That is not measurement. It is picking the answer you liked.
Who you split, and who you count
Every experiment splits something into groups. Most of the time it is people, but it does not have to be, and the choice matters more than it looks. Two ideas are worth naming.
The unit of randomisation is the thing the coin is tossed for. Common choices:
- A person, recognised by their account when they log in. The same person sees the same version on every visit and every device.
- A device or browser, recognised by a cookie. Good when people do not log in; the same person on a phone and a laptop counts as two.
- A session: one visit. Each visit can get a different version.
- A page view or a request: every single page load is tossed separately. Common for back-end changes such as search ranking.
The unit of analysis is what your metric counts per: bookings per person, clicks per page view, revenue per session.
Toss the coin for the same thing you count.
The statistics in this book assume that every unit in a group is independent of the others and sees only one version. Randomise by person and count per person, and that holds. Randomise by page view and count bookings per person, and one person sees both versions on different pages: the groups contaminate each other, observations are no longer independent, and the intervals come out narrower than they should be, so you see effects that are not there.
For most product changes, the right unit is the person. People notice when a page changes under them, they come back, and they remember. If you can only recognise devices, accept that a person on two devices counts twice and a cleared cookie becomes a new person, and keep that in mind when results look odd.
A cleared cookie is not an edge case any more. Safari limits cookies written by a page’s scripts to seven days, so in a three-week test that identifies people with such a cookie, one returning Safari user can appear as two or three “people”, each landing in a group by a fresh coin toss and possibly seeing both versions. Metrics about returning visitors are the first to suffer: someone who comes back after ten days is counted as new. Cookies set by the site’s own server are not capped in the same way, which is one reason platforms assign on the server. And consent banners decide who can be identified at all: whoever declines may not be in the experiment, so the people you count are the ones who agreed to be counted.
How the coin is actually tossed
Nobody flips a coin for each visitor. The platform takes the person’s id and the experiment’s name, runs them through a hash, a function that turns any text into a number that looks random but is always the same for the same input, and uses the number to put the person in a bucket: buckets 0 to 49 see A, 50 to 99 see B. Three useful things follow. The same person lands in the same group on every visit and every server, without anyone storing who saw what. Different experiments hash differently, because the experiment’s name is part of the input, so being in B in one test says nothing about another; reusing an old experiment’s name, or its salt, would put the same people in B again and drag in whatever the last test left behind (chapter 8). And it can be done the moment a person arrives.
Which raises the difference between assignment and exposure. A person can be assigned at login and never reach the page where the versions differ. Counting everyone who was assigned is honest but dilutes the effect; counting only those who were exposed is the triggering described below, and it is only fair if exposure is decided the same way in both groups.
Ratios and the delta method
Many useful metrics are ratios: clicks per page view, revenue per session. When the denominator is not the unit of randomisation, the observations are not independent and the naive variance is wrong.
The delta method gives the variance of a ratio of two per-user sums, R = ΣY/ΣX:
Here n is the number of users in the group; for each user, Y is their total of the numerator (their clicks) and X their total of the denominator (their page views); X̄ is the average of X per user; σ²Y and σ²X are the variances of those per-user totals across users (chapter 4), and σXY is their covariance: how much a user’s clicks and page views rise and fall together. The square root of Var(R) is the standard error of the ratio, used exactly like any other.
A worked example, with an illustrative mix of users. 95,000 users in a group see on average 3 page views each (standard deviation 4) and click on average 0.6 times each (standard deviation 1.2); a user’s clicks and page views have a correlation of 0.6, so σXY = 0.6 × 4 × 1.2 = 2.88. Clicks per page view is R = 0.6/3 = 0.20, and the delta method gives Var(R) = (1.44 − 2 × 0.2 × 2.88 + 0.04 × 16)/(95,000 × 9), a standard error of 0.00104. Treating the 285,000 page views as if they were independent people would give √(0.2 × 0.8/285,000) = 0.00075: about 28% too small, which is exactly how intervals come out narrower than they should be.
Slowly, with numbers
In wordsInside the bracket: the variance of the clicks, minus a correction for clicks and page views rising together, plus the variance of the page views scaled down by the ratio squared. Outside: divide by the number of users times the average page views squared.
- ≈
- Approximately equal: the formula is a very good approximation once there are thousands of users.
- σ²Y
- Sigma squared: the variance of clicks per user. The standard deviation, 1.2, squared: 1.44.
- σ²X
- The same for page views per user: 4 squared, 16.
- σXY
- The covariance. For each user, take how far their clicks are above average and how far their page views are above average, multiply, and average over users. It is positive when heavy viewers are heavy clickers. Here 2.88.
- R
- The ratio itself: 0.6 clicks / 3 page views = 0.20.
With numbersThe bracket: 1.44 − 2 × 0.2 × 2.88 + 0.2² × 16 = 1.44 − 1.152 + 0.64 = 0.928. The bottom: 95,000 × 3² = 855,000. Divide: 0.00000109. Square root: 0.00104.
Also watch the denominator itself: if the change alters how many page views there are, a per-page-view metric can move with no change in what users experienced.
Four kinds of metric
Ron Kohavi, Diane Tang and Ya Xu describe the metrics an organisation uses in layers. In our words:
Goal
What the business ultimately exists to improve: long-term revenue, retained customers, trips taken. Slow to move, hard to attribute to one change.
Driver
Shorter-term behaviours believed to lead to the goal, and sensitive enough for a two-week test: searches that end in a booking, visitors who return within a week.
Guardrail
Things that must not get worse even if the driver improves: page speed, errors, cancellations, complaints, unsubscribes.
Trust
Checks that the experiment itself works: did each group get the share of people it should, is every event being logged, does a test of two identical versions find nothing. They say nothing about the product and everything about the data (chapter 8).
Same ideas, many names
You will meet these layers under other names, depending on the company, the vendor and the book. The vocabulary is not standardised; the ideas are.
- Goal metric
- North Star metric, company KPI, true-north metric
- Driver metric
- primary metric, success metric, decision metric, leading indicator, proxy or surrogate metric
- Guardrail metric
- counter-metric, health metric, do-no-harm metric; often grouped with “secondary metrics”
- Trust metric
- data quality check, validity check, trust-related guardrail, SRM (sample ratio mismatch) check
It is worth being clear about which part of this is science. The method underneath, randomised controlled comparison and the statistics used to read it, is mature: it comes from agriculture and medicine, and has a century of theory and practice behind it. The layer on top, how companies name and organise their metrics, is industry convention. It is useful, often wise, and still a set of habits rather than laws. Do not argue about names; agree on definitions, and write them down (chapter 13).
Decide on one metric before the test. Do not accept a win that breaks another.
The one thing: the overall evaluation criterion
When several metrics matter, Kohavi, Tang and Xu’s Trustworthy Online Controlled Experiments recommends combining them, ideally, into a single overall evaluation criterion, the OEC: one measure that the organisation believes causally drives its long-term goals.
It can be a single driver metric or a weighted mix. What matters is that it is chosen before the test and used for every test of that kind.
Picking it is a judgement about the business, which is why it cannot be left to the analyst alone. Revenue is the classic trap: a test can raise short-term revenue by filling a page with ads or pushing expensive options, and pay for it in customers who never return. Kohavi’s book uses exactly this example to argue that revenue on its own is not enough as an OEC.
What makes a metric good for experiments
Four tests a metric has to pass before it can decide an experiment.
- It moves when the experience changes. A metric that never moves in a two-week test is useless for decisions, however important it is.
- It points the right way. Up must mean better. Time on page is the standard counter-example: more time can mean engaged, or lost.
- It is hard to game. If a variant can raise it without making anything better for anyone, someone eventually will.
- It predicts the long term. Short tests measure short effects. The driver earns its place only if moving it has, historically, moved the goal.
These are the four tests every candidate metric has to pass; chapter 13 describes how mature teams run them before a metric is allowed to decide anything.
Count only who could notice
Most changes touch only part of a product. A new price filter only matters to people who use filters; a new payment page only to people who reach payment.
Everyone else gets exactly the same experience in both groups, so their behaviour cannot carry any signal about your change. It can only add noise.
Counting them anyway has two costs. The effect gets diluted: a 5% improvement for the people who saw the change becomes a much smaller improvement averaged over everyone. And the test gets noisier, because it carries the random wobble of all the people who never noticed anything.
Here is the price-filter example as pages.
Three pages of one visit, one of them changed
How to read itWireframes of three pages a visitor to a hotel site might pass through. The test changes the price filter on the search results, drawn in blue. The other pages are identical in A and B.
Who to count in a price-filter test
How to read itA price-filter redesign helps only the people who use the filter. Each square is a visitor: blue ones use the filter and see the change, grey ones never do. Move the slider to change how many people use it. The numbers below compare two ways of analysing the same test: counting every visitor, or counting only the people who reached the filter. Watch how much the effect is watered down, and how many more visitors the first way needs, when few people use the feature. This is why the chapter recommends counting only the people who could notice.
- Effect, counted over everyone
- —
- Visitors per group, counting everyone
- —
- Visitors per group, counting only filter users
- —
- Counting everyone needs
- —
Analysing only the people who reached the point where the versions differ is called triggering. The condition must be applied the same way in both groups: in control, count the people who would have seen the new filter, because they used the old one. A condition that only the variant can satisfy, such as “clicked the new button”, creates the very mismatch chapter 8 warns about.
When the change is below the fold
Triggering gets tricky when what decides who reaches the change is the visitor’s own behaviour. Take a change near the bottom of a long product page on a phone, where most visitors never scroll that far.
A change most visitors never see
How to read itWireframes of the same product page on a phone, A and B. The dashed red line is the fold: what fits on the screen before any scrolling. The change, drawn in blue, is far below it. The red dot is the point where the page records that a visitor has scrolled far enough to see the section, in A as well as in B.
There are three ways to run this test, and only one of them is safe.
Toss the coin when the page loads, and count everyone. Fair, but most of the people counted never saw the change, so the effect is diluted and the test needs far more visitors, exactly as in the filter example above.
Toss the coin only when a visitor scrolls down to the section. Tempting, and risky. If anything about the two versions changes how many people get that far, for example B makes the page a little longer, or its section loads a moment later and some visits end first, the two groups stop being the same size and the same kind of people. Chapter 8 calls this a sample ratio mismatch, and a result with one cannot be trusted.
Toss the coin on load, but count only the people who scrolled that far, in both versions. Every visitor gets a version as usual, and the page records the moment they reach the section’s position, in A as well as in B, even though A has nothing new there. The analysis keeps only the people with that record. The groups stay fair, because the coin was tossed before anyone scrolled, and the noise of the visitors who never got there is left out.
If being counted depends on what visitors do, record it the same way in both versions.
That is the general rule for triggering on behaviour: whenever being in the analysis depends on something the visitor does after the page loads, check that the condition is recorded at the same point in both versions, and check that the groups it keeps are still the size the coin intended.
In practice
Four things to settle in the plan, before the test starts.
- Write down the unit, the one deciding metric and the guardrails before you build the variant.
- Use the same OEC for every test on the same product area, so results can be compared and added up.
- Give every guardrail a threshold: how much worse is too much. It is checked against the lower end of the interval, not against significance (chapter 9).
- Define triggering in the plan, and check that both groups trigger at the same rate.
What we’ve learned
- Randomise and count the same unit, usually the person.
- Metrics come in layers: goal, driver, guardrail and trust.
- Decide on one metric before the test, and refuse wins that break a guardrail.
- A good metric moves, points the right way, resists gaming and predicts the long term.
- Count only the people who could notice the change, the same way in both groups.
Sources
- Kohavi, R., Tang, D. and Xu, Y. (2020). Trustworthy Online Controlled Experiments. Cambridge University Press. Chapter 6, Organizational Metrics; chapter 7, Metrics for Experimentation and the Overall Evaluation Criterion; chapter 20, Triggering.
- Spotify Confidence glossary: north star metric and success metric. Mixpanel, Guardrail metrics; Statsig, counter metrics. Names in industry use.
- Dmitriev, P., Gupta, S., Kim, D. W. and Vaz, G. (2017). A Dirty Dozen: Twelve Common Metric Interpretation Pitfalls in Online Controlled Experiments. KDD 2017.
- Deng, A. and Shi, X. (2016). Data-driven metric development for online controlled experiments: seven lessons learned. KDD 2016.
- WebKit (2019). Intelligent Tracking Prevention 2.1. Script-set cookies capped at seven days.
- Georgiev, G. Z. “When Session-Based Metrics Lie”, Analytics-Toolkit blog. On per-session metrics.