Trustworthy Online Controlled Experiments

Ron Kohavi, Diane Tang and Ya Xu (2020). A practical guide to A/B testing. The key visuals, chapter by chapter.Rahul's Site
1

Introduction and motivation

Most ideas do not work

WhatEach row is 100 tested ideas. Red = ideas that improved the metric they were built to improve, as each company reported.

So whatEven good teams win only 10 to 33% of the time. If you ship without testing, you ship the losers too.

Small changes, big money

WhatYearly value of single experiments, on a log scale. The book gives most values as ranges ("tens of millions"), so bars show the range.

So whatThe biggest win in Bing's history was a few days of work that sat in the backlog for six months. Nobody can rank ideas by gut.

Bing Ads: growth comes inch by inch

WhatEach bar is one monthly "package" of shipped experiments and its revenue change. The line compounds them. The authors perturbed the numbers.

So whatAbout 20% growth a year came from many 0.1-2% steps, and some months were negative. Large gains are many small gains added up.

Read from the book's Figure 1.4 (RPM, July 2013 to October 2015). Two "new models" packages are placed in the nearest month.

2

Running and analyzing experiments

A coupon field nobody can use still costs money

WhatA "painted door" test: a coupon code box at checkout, with no real coupons. Dot = change in revenue per user. Bar = 95% confidence interval. Grey band = the 1% change the business cares about.

So whatBoth designs cut revenue (by 2.8% and 7.8%). The test killed the coupon plan before anyone built it.

Table 2.1. Control revenue per user $3.21.

Who goes in the denominator?

WhatThe shopping funnel. The change is on the checkout page. Three choices for "revenue per user".

So whatCount users who started checkout. All visitors adds noise. Only buyers hides the main effect, because the change alters how many people buy.

Launch or not? Six results, one rule

WhatRows 1-6 are the book's six example results. Dashed lines = practical significance (the smallest change worth acting on). The last row is yours: move the sliders.

So what"Not significant" can mean "no effect" (case 1) or "not enough data" (case 4). The interval, not the p-value, tells you which.

3

Twyman's law and experimentation trustworthiness

Peek every day and 1 in 5 A/A tests "wins"

WhatA/A tests: both groups get the same thing, so every "win" is false. Each line is one test's z-score as data comes in over 14 days. Red = crossed the significance line at some peek.

So whatChecking every day and stopping at the first "significant" result finds a fake winner far more often than 5%. Fix the duration up front, or use sequential tests built for peeking.

MSN: a 0.8% user gap flipped the answer

WhatCurve = sample ratios you get by chance with 800,000 users per group. MSN saw 0.992. Bars = the result before and after the bug was found.

So whatA tiny sample ratio mismatch (SRM) means a bug. Here, the best users were tagged as bots and dropped. The loss was really a 3.3% gain.

Ad click-through rate by phone system

WhatClick-through rate on Bing mobile ads, by operating system.

So whatUsers did not differ. Logging did: Android used a lossy beacon, and Windows Phone logged swipes as clicks. Surprising numbers are usually bugs.

Read from the book's Figure 3.6.

Simpson's paradox in a ramp-up

What1M visitors a day. Friday, 1% go to Treatment. Saturday, 50%. Bubble size = users. Treatment converts better on each day.

So whatAdded together, Treatment looks worse, because most of its users came on Saturday, a weak day. Never pool periods that ran at different splits.

Table 3.1. Treatment total is 6,230 / 510,000 = 1.22% (the book rounds to 1.20%).

4

Experimentation platform and culture

Crawl, walk, run, fly

WhatExperiments per year at each maturity phase (log scale). Each phase runs 4-5 times more than the last.

So whatGoogle, LinkedIn and Microsoft are past 20,000 a year. At that scale you need a platform, not people.

Growth after the first year at 365+ experiments

WhatExperiment count, as % growth over year 1 (the year each company first ran more than one experiment a day).

So whatTen times the volume in four years. Office grew 600% in one year because Bing's platform already existed.

Read from the book's Figure 4.1.

One layer or many?

What1,000 hash buckets. In one layer, each user is in one experiment, so experiments split the traffic. In overlapping layers, each user is in every experiment, one per layer.

So whatOne layer caps you at a few experiments: with 10, each sees a tenth of users and can detect only changes 3.2 times larger. Layers give every experiment full power.

5

Speed matters

Slow the site down to price speed

WhatNobody can make a site faster on demand, so Bing made it slower. Black dot = today. Red = the measured result of a slowdown, with its confidence interval. Shaded fan = all slopes that fit.

So whatIf the curve is close to a straight line near today, the loss from 100 ms slower equals the gain from 100 ms faster. A 250 ms delay pins the slope down better than 100 ms.

Curve shape is illustrative. Bing found the 250 ms effect was about 2.5 times the 100 ms effect, which supports the straight-line assumption.

What a few milliseconds are worth

WhatLeft: effect of 100 ms. Right: the speed-up that pays one engineer's full yearly cost at Bing.

So whatIn 2017, every 100 ms at Bing was worth $18M a year. By 2015, 4 ms paid for an engineer. Use latency as a guardrail on every experiment.

"Page loaded" is not when the user sees it

WhatSeconds until the visible part of the page renders (above the fold) and until the browser's onload event fires.

So whatAmazon looks ready 3.2 s before onload. Gmail fires onload 1.5 s before anything useful shows. Measure what the user sees, or time to first click.

6

Organizational metrics

Goal, driver, guardrail: the role depends on the team

WhatThe same metrics sorted for two teams. Goal = what success is. Driver = fast, sensitive signs you are moving toward it. Guardrail = what must not break.

So whatLatency is a guardrail for a product team and the goal for an infrastructure team. Each team must say how its metrics connect to the company goal.

Revenue per user = who buys × how much

WhatArea = revenue per user. Width = share of users who buy. Height = average spend per buyer. Two Treatments both add 10% revenue.

So whatSplit revenue into a 0/1 "did they buy" metric and spend per buyer. Same total, very different stories, and the 0/1 metric has lower variance.

Illustrative numbers.

When a measure becomes a target

WhatReal incentives from the book's gameability examples, and how people gamed them.

So whatAny number tied to a reward gets gamed. Prefer metrics of user value, add quality limits, and avoid counts of your own actions.

7

Metrics for experimentation and the OEC

More metrics, more false alarms

WhatChance that at least one of k independent metrics shows p < 0.05 when the change does nothing: 1 - 0.95ᵏ.

So whatFive key metrics give a 23% chance of a false signal. Keep key metrics to about five, or combine them into one Overall Evaluation Criterion (OEC).

Amazon e-mail: put a price on an unsubscribe

What30 e-mail campaigns (simulated). Bar = revenue per recipient minus unsubscribes × lifetime loss per unsubscribe. Red = the campaign loses money.

So whatRevenue alone always says "send more e-mail". With just a few dollars per unsubscribe, more than half of Amazon's campaigns went negative.

OEC = (Σ revenue - unsubscribes × lifetime loss) / users. Campaign values simulated.

A broken ranker looked like a big win

WhatA bug showed users very poor search results. Left: how two company metrics moved. Right: query volume split into three factors.

So whatBad results force more queries and more ad clicks. Queries per session going up can mean users struggle. Sessions per user is the factor to grow: happy users come back.

8

Institutional memory and meta-analysis

Ship everything vs ship only proven winners

What60 ideas in a row. As at Microsoft, a third help, a third hurt and a third do nothing. Navy = ship every idea. Red = ship only ideas whose experiment was significantly positive.

So whatWithout experiments, good and bad launches cancel out. Your record of past experiments is what shows this.

Simulated: effects of +1, -1 or 0 units, each measured with noise (standard error 0.45).

The winner's curse

What200 experiments with small true effects (x) and noisy measurements (y). Red = significant and shipped.

So whatPicking the significant ones also picks lucky noise, so shipped results look bigger than they are. Re-run winners, or shrink the estimates, before you add them up.

Simulated. Lee and Shen (2018) found this bias across experiments at Airbnb.

9

Ethics in controlled experiments

OKCupid: what pairs were told vs the truth

WhatPairs that the algorithm rated 30%, 60% or 90% matches were each told 30%, 60% or 90%. Navy = told the truth. Red = told something false.

So whatTwo thirds of pairs were deceived. Testing a feature is not the same as testing what happens when you lie to people.

Identified to anonymized

WhatFour levels of user data, from most to least able to point at one person.

So what"Anonymous" is not "anonymized". As sensitivity and re-identification risk rise, so must access control, auditing and security.

Where does an experiment sit?

WhatExperiments sorted by two questions: is the Treatment known to be worse for users, and does it deceive them?

So whatIf you would ship a change to everyone without a test, testing it on half is fine. Deception and power-of-suggestion studies need real review.

10

Complementary techniques

Depth per user vs number of users

WhatMethods that sit next to A/B tests, by how many users they reach (left to right) and how much they learn about each user (bottom to top). Hover for what each is good for.

So whatSmall, deep methods find ideas and explain "why". Large, shallow methods confirm "what" at scale. Use several to bound the answer.

Positions follow the book's Figure 10.1; it does not give numbers. Human evaluation and external data vary.

11

Observational causal studies

Yahoo! display ads: observational vs experimental lift

WhatLift in brand searches after a display ad, estimated by observational methods on 50M users vs measured by a controlled experiment.

So whatThe observational estimate was 160 to 220 times too high. People active on Yahoo! that day both saw the ad and searched.

Lewis, Rao and Reiley (2011).

52 observational claims, tested in trials

WhatEach square is one medical claim from observational studies that was later tested in randomized trials (Young and Karr 2019).

So whatNone of the 52 replicated. Five came out significant in the opposite direction.

Errors "reduce" churn: a common cause

WhatSimulated users of an Office-like product. Heavy users see more errors and churn less. Toggle to compare users with the same usage.

So whatWithin each usage group, errors do nothing. Usage drives both. Do not add errors to cut churn: run an experiment.

Simulated data.

Regression discontinuity: the 21st birthday

WhatUS deaths per day around the 20th, 21st and 22nd birthdays. At 21, drinking becomes legal.

So whatOnly the 21st has a jump, so it is not a birthday-party effect. A sharp threshold can stand in for random assignment.

Approximate, after the book's Figure 11.2 (Angrist and Pischke 2014).

Difference in differences

WhatTV ads start in one market at T1. A similar market without ads is the Control. Its change over the same period is the counterfactual.

So whatEffect = change in Treatment minus change in Control. It only works if both would have moved in parallel. Break that and see.

Illustrative numbers. True effect = +6.

12

Client-side experiments

Server change vs app change

WhatTime from "code ready" to "all users have it", for a server change and for code shipped inside a mobile app.

So whatPlan app experiments early. Build every variant into the release behind a flag and set parameters from the server, so you can fix or stop without a new release.

Durations are typical, from the chapter's text.

Who is in your app experiment on day N?

WhatUsers must update the app and then open it again before they get their variant. Daily users arrive first. Weekly users arrive late.

So whatEarly app results over-represent heavy users. Run longer, and compare Treatment and Control over the same window.

Simulated: one third each of daily, every-3-days and weekly users. App update adoption follows the one-week ramp the book describes.

13

Instrumentation

Logging a click: fast or reliable

WhatTwo ways to log that a user clicked a link. Top: a web beacon sent as the next page loads. Bottom: a redirect through your server.

So whatBeacons are fast but can be lost. Redirects never lose a click but add delay. Ad clicks are billed, so they use the redirect.

Client logs vs server logs

WhatWhat each side can see.

So whatYou need both, joined on a shared ID. Never subtract a client time from a server time: device clocks can be years off.

14

Choosing a randomization unit

Pick a randomization unit

WhatBars = units per user per week. Smaller units give more samples and more power. Larger units keep each user's experience consistent and allow user-level metrics.

So whatRandomize by user unless you have a reason not to. The randomization unit should be the same as, or larger than, the unit your metrics count.

Unit counts are relative and illustrative (a user with 3 sessions a week, 3 queries per session, 1.5 pages per query).

Which user ID?

WhatFour IDs for user-level randomization, scored on the book's questions.

So whatA signed-in ID is best when it exists. Use cookies or device IDs for flows that cross sign-in. Use IP addresses only for infrastructure tests.

15

Ramping experiment exposure

Four ramp phases

WhatShare of users in Treatment over the life of one launch.

So whatRamp fast through small rings to catch bugs. Stay at 50% (the maximum power ramp, MPR) for a week to measure. Ramp past it only for load. Hold back only when you must learn the long-term effect.

Day lengths are illustrative. Bing first ramps one data center at 0.5-2%.

Why 50/50 is the maximum power ramp

WhatWith all traffic in the test, the variance of the difference is proportional to 1/(q(1-q)), where q = share in Treatment.

So what50/50 needs the fewest days. A 90/10 holdout needs 2.8 times as long to see the same effect, so a weak long-term effect may be better measured at 50/50.

16

Scaling experiment analyses

From raw logs to a scorecard

WhatThe batch pipeline (top) and the near-real-time path (bottom).

So whatThe fast path only counts and alerts, so bad experiments stop within minutes. The slow path cleans, enriches and runs the statistics you decide on.

A scorecard you can trust

WhatA simulated scorecard. Metrics are grouped by tier and shown as % change. Color only when significant: teal = good change, red = bad change, navy = moved with no clear good side.

So whatCheck the sample ratio first: if it fails, hide everything else. Use stricter thresholds for metrics you did not expect to move.

Tiered = 0.05 for metrics you expect to move, 0.01 for ones that may move, 0.001 for ones that should not (Chapter 17). Values simulated.

17

The statistics behind online controlled experiments

How many users do you need?

WhatUsers per variant for 80% power at p < 0.05: n ≈ 16σ²/δ², where δ is the smallest change you care about. For a conversion rate p, σ² = p(1-p).

So whatHalving the change you want to detect needs 4 times the users. A 5% change on a 5% conversion rate needs 121,600 users per variant.

The average turns normal

WhatRevenue per user is very skewed (left inset). Bars = averages of n users, drawn 3,000 times. Red curve = the normal curve the t-test assumes.

So whatThe t-test needs normal averages, not normal data. Rule of thumb: n > 355 × skewness². Capping revenue at Bing cut skewness from 18 to 5 and the needed n from 114k to 10k.

Simulated lognormal revenue, skewness about 6.

p < 0.05 is not "95% sure it works"

What1,000 ideas. The success rate is the share that truly work. Experiments have 80% power and a 5% false positive rate.

So whatWhen only 1 in 10 ideas works, about a third of significant "wins" are false. The p-value says how surprising the data is if nothing changed, not how likely the change is real.

18

Variance estimation and improved sensitivity

One outlier can erase a real effect

WhatTreatment truly beats Control. One extreme user is added to Treatment. Grey dots = t-statistics from repeated simulations at each outlier size. Red = your current outlier.

So whatThe outlier raises the mean, but raises the variance far more, so a clear win becomes "not significant". Cap values (for example, 500 searches a day) before testing.

Simulated: 100 users per group, true effect 1 standard deviation, as in the book's Figure 18.1.

CUPED: use last month to cancel noise

WhatEach dot is a user (simulated): last month's sessions vs this month's. CUPED subtracts the part of this month that last month predicts.

So whatVariance falls by the factor 1 - ρ², where ρ is the correlation. With ρ = 0.7, you need half the users for the same power.

19

The A/A test

A/A p-values should be flat

What1,000 simulated A/A tests (no real difference). Bars = how often each p-value came up. A healthy system gives a flat histogram: 5% of p-values fall below 0.05.

So whatEach failure has a shape. Too many small p-values: wrong variance formula. A pile near 0.32: one huge outlier. Gaps: a rare 0/1 event.

Two honest ways to compute click-through rate

WhatTwo users. Pooled CTR divides all clicks by all pages. Per-user CTR averages each user's CTR.

So whatSame data, 67% vs 50%. Both are valid. The pooled one needs the delta method for its variance, because pages from one user are not independent.

Bugs that A/A tests caught

WhatReal cases from the chapter.

So whatRun A/A tests before you trust a platform, and keep running them next to your A/B tests.

20

Triggering for improved sensitivity

Analyze only users who could see the change

WhatA checkout change on a site where 5% of visitors buy. The goal is to detect a 5% change in conversion. Bars = visitors you need with and without triggering on "started checkout".

So whatUsers who never reach checkout have zero effect and only add noise. In the book's example, triggering halves the users needed: 121,600 vs 64,000.

+3% for 10% of users is not +0.3%

WhatTriggered users are 10% of users and gain 3% revenue. The overall gain depends on their share of revenue, not their share of users.

So whatDilute by the triggered users' share of the metric. Checkout users carry all revenue (3%). Low spenders carry 1% (0.03%).

A small idea that grew: links in a new tab

WhatClicks per user at MSN when links opened in a new tab.

So whatA big effect on a tiny segment rarely matters by itself. It is worth chasing when the idea can generalize.

21

Sample ratio mismatch and trust guardrails

Sample ratio mismatch check

WhatEnter users per variant for a 50/50 design. The line shows the p-value for the same ratio at different sizes.

So whatA 0.993 ratio is normal for 1,000 users and a bug for 1.6 million (p = 1 in 500,000). With large samples, stop at ratios beyond 0.99 or 1.01.

Bing: five "wins" from one browser bug

WhatFive success metrics. Grey = all users, with an SRM (ratio 0.9938, p = 2e-5). Red = the 96% of users without an old Chrome version (ratio 0.9993, p = 0.66). Filled = significant.

So whatRemove the broken segment and every effect is gone. With an SRM, do not read the metrics.

Read from the book's Figure 21.1. Only the first metric is named.

How common the problem is

WhatShare of experiments with an SRM at Microsoft, and share of Bing traffic removed as bots.

So whatBot filters remove most traffic, so a small change in who gets flagged can create an SRM.

22

Leakage and interference between variants

Which way does leakage push the result?

WhatBook examples where Treatment users affect Control users. Left: the measured effect is too small. Right: too large. Navy = direct links between users. Red = shared resources.

So whatSocial features leak benefit into Control. Marketplaces and budgets let Treatment take from Control. Know the direction before you trust the number.

Randomize by cluster to cut leakage

WhatA simulated social network of 240 people in 12 friend groups. Red = Treatment, navy = Control. Grey links cross from one variant to the other.

So whatRandomizing groups instead of people cuts the links that leak, but gives fewer units and less power. On LinkedIn, even 10,000 clusters left over 80% of links between clusters.

23

Measuring long-term treatment effects

More ads: short-term win, long-term loss

WhatTreatment shows more ads. Red = measured revenue effect each week. After week 12, both groups get the same ads (post-period). Any gap left is what users learned.

So whatUsers learn to ignore ads, so the effect shrinks or turns negative. The post-period gap measures that learning without other launches or the season mixing in.

Illustrative curves, after the post-period design in Hohnhold, O'Brien and Tang (2015).

Staggered starts show when to stop

WhatThe same Treatment starts twice, two weeks apart (T0, T1). Their gap is an A/A test of exposure time.

So whatWhen the gap is no longer significant, learning has converged and the long-term effect can be measured.

Illustrative.

Four designs, what each fixes

WhatWays to measure long-term effects, against the problems of just running longer.

So whatNone fixes everything. Pick by your goal: attribution, learning, or a rule that predicts the long term from the short term.

From Trustworthy Online Controlled Experiments: A Practical Guide to A/B Testing by Ron Kohavi, Diane Tang and Ya Xu (Cambridge University Press, 2020). Numbers as reported in the book. Simulations and illustrative values are labelled.