GARETH GRANTTECHNOLOGY · DATA · INNOVATION
Explore

21 / Inference

A/B testing for conversion rates

A fixed-horizon A/B test compares two independently assigned experiences using a predefined outcome. Conversion counts can estimate an absolute rate difference, its uncertainty and an economic consequence, while random allocation helps separate the experience from differences in the visitors receiving it.

IntermediateLive exploration + Python

The business question

Does a changed offer or customer journey improve conversion enough to justify rollout?

  • Test a checkout change using completed purchases per eligible visitor.
  • Compare two booking reminders on attendance or confirmed appointments.
  • Evaluate a service message while protecting revenue, complaint and cancellation guardrails.

How the method works

The analysis needs a precise denominator and one consistent success definition. If the unit is a visitor, repeated sessions from that visitor should not be treated as independent people. Randomly allocate eligible units, keep the allocation stable and measure both groups over comparable exposure and follow-up windows. Record assignment failures and outcome completeness.

For a large-sample test of equal proportions, the null hypothesis pools the success counts to estimate one common conversion probability. The observed difference is divided by the standard error under that null to produce a z statistic. A confidence interval for the difference uses the two groups’ separate estimated variances; that is a different standard error for a different purpose.

Absolute percentage-point change is the quantity most directly connected to extra orders. Relative lift divides that change by the baseline and can sound much larger. Convert plausible rate differences into contribution only after accounting for discount, fulfilment and intervention costs. Define the horizon, sample size, primary outcome and multiplicity plan in advance; repeatedly stopping when significance appears invalidates this ordinary fixed-horizon calculation.

The calculation

difference = p_B−p_A; pooled p = (x_A+x_B)/(n_A+n_B); z = difference/√[pooled p(1−pooled p)(1/n_A+1/n_B)]
Read the symbols
SymbolMeaning
x_A, x_BSuccess counts from independently assigned units.
n_A, n_BEligible units with the defined outcome window.
p_A, p_BObserved success proportions in each arm.
differenceAbsolute rate change; multiply by 100 for percentage points.

A worked business example

ILLUSTRATIVE SCENARIO

Illustrative online retailer testing a clearer checkout on independent eligible visitors.

Inputs

  • Control A: 80 purchases from 1,000 visitors, or 8%.
  • Variant B: 110 purchases from 1,000 visitors, or 11%.
  • Contribution per extra purchase is assumed R120 before any new intervention cost.

Work through the numbers

  1. Absolute difference = 0.11−0.08 = 0.03, or 3 percentage points; relative lift is 37.5%.
  2. The pooled null conversion estimate is 190/2,000 = 0.095.
  3. The two-sided large-sample z test gives z≈2.288 and p≈0.022149.
  4. A separate unpooled normal interval for the difference is approximately 0.433–5.567 percentage points.
At the observed difference, 1,000 comparable visitors would produce 30 extra purchases and R3,600 in extra contribution before new costs.

The lower and upper interval endpoints imply materially different business cases. This calculation assumes a well-run randomised test; it does not promise that the observed lift will persist after rollout.

Explore the decision

Compare two conversion rates. The live explorer has its own example inputs; it is separate from the worked calculation above.

Enable JavaScript to use this calculator. The worked example and executable Python remain available.

Apply it at work

  1. Define the randomisation unit, primary success metric, guardrails, minimum worthwhile lift and fixed stopping rule.
  2. Check assignment balance, instrumentation and comparable follow-up before interpreting outcomes.
  3. Report the two conversion rates, absolute and relative difference, interval and planned test.
  4. Apply contribution and operating constraints, then validate the result during controlled expansion.

Check these assumptions

  • The two arms contain independent Bernoulli units with no material cross-arm contamination.
  • Randomisation and measurement are implemented correctly, including the intended exposure denominator.
  • Counts are sufficiently large for the normal approximation; sparse outcomes require another method.
  • The fixed horizon and analysis plan are respected, including adjustment for multiple variants or outcomes.

Common mistakes and how to avoid them

  • Repeated peeking and optional stopping can inflate false positives under this fixed-horizon method.
  • Counting repeat visits as independent people understates uncertainty and can distort the target population.
  • Optimising conversion alone can encourage discounts or low-quality orders that reduce contribution.

How this can help the business

  • Product teams can evaluate a change against an explicit economic threshold instead of the most attractive headline percentage.
  • A clear test plan can reduce the cost of deploying a change that looks promising on a biased or underpowered comparison.
A decision rule to adapt

Roll out when the practical effect, uncertainty, implementation cost and guardrails jointly meet the pre-agreed decision standard; investigate surprising assignment or tracking problems first.

When to use another approach

Use exact methods for sparse counts, cluster-aware methods for grouped assignments, or a correctly designed sequential method when continuous monitoring is required.

Reproduce the worked example in Python

The code is self-contained for this example. Dependencies and run instructions are included with the downloadable notebook.

Show executable code and recorded output
import numpy as np
from scipy import stats
a_success, a_n = 80, 1000
b_success, b_n = 110, 1000
a_rate, b_rate = a_success/a_n, b_success/b_n
difference = b_rate - a_rate
pooled = (a_success+b_success)/(a_n+b_n)
test_se = np.sqrt(pooled*(1-pooled)*(1/a_n+1/b_n))
z = difference/test_se
p = 2*stats.norm.sf(abs(z))
interval_se = np.sqrt(a_rate*(1-a_rate)/a_n + b_rate*(1-b_rate)/b_n)
low, high = difference-1.96*interval_se, difference+1.96*interval_se
print("Lift (percentage points):", round(100*difference, 3))
print("Two-sided z and p:", round(z, 3), round(p, 6))
print("Approximate 95% CI (points):", round(100*low, 3), round(100*high, 3))
print("Illustrative extra contribution / 1000 visitors (R):", round(1000*difference*120, 2))

Recorded output

Lift (percentage points): 3.0
Two-sided z and p: 2.288 0.022149
Approximate 95% CI (points): 0.433 5.567
Illustrative extra contribution / 1000 visitors (R): 3600.0
Download all worked examples

Sources and further reading

Concepts are linked to primary teaching or technical sources. The business examples are illustrative applications, not reported client results.