Below is a step-by-step recipe you can reuse any time you have several page variants and you just want to know:
- “Is there ANY real difference among them?”
- “If so, WHICH pairs are different?”
I’ll assume you already have, for each variant,
• n = number of visitors shown that variant
• k = number of conversions
• p̂ = k / n = observed conversion rate
I’ll call the three variants A, B, and C, but you can generalise to 4, 5, … variants with the same workflow.
────────────────────────────────────────────
- Put all the data in a 2 × 3 contingency table
────────────────────────────────────────────
Conversions Non-Conversions Total
-----------------------------------------------------
Variant A kA nA–kA nA
Variant B kB nB–kB nB
Variant C kC nC–kC nC
-----------------------------------------------------
Total kΣ (=kA+kB+kC) (nΣ–kΣ) nΣ
────────────────────────────────────────────
2. Global test: “Is at least one variant different?”
────────────────────────────────────────────
Use a χ² test of independence (large samples) or Fisher’s exact test (if any expected cell count < 5).
Null hypothesis H₀: The conversion probability is the same for all variants.
Chi-square statistic
χ² = Σᵢ Σⱼ (Oᵢⱼ – Eᵢⱼ)² / Eᵢⱼ, with df = (rows–1)·(cols–1) = (2–1)·(3–1) = 2.
Here Eᵢⱼ = (row total × column total) / grand total.
Quick formula (large n) that skips the 2 × 3 table:
• Let p̂_pool = kΣ / nΣ
• χ² = Σ_variants ( kᵢ – nᵢ p̂_pool )² / [ nᵢ p̂_pool (1–p̂_pool) ]
• df = 2.
Compute the p-value from a χ² distribution with 2 df.
If p ≥ α (commonly 0.05), stop: you have no evidence of any difference.
If p < α, proceed to pairwise comparisons.
────────────────────────────────────────────
3. Pairwise tests: “Which variant beats which?”
────────────────────────────────────────────
For each pair (A vs B, A vs C, B vs C) run a two-proportion z-test:
z = ( p̂₁ – p̂₂ )
───────────────────────────────
√[ p̂_pool (1–p̂_pool)(1/n₁ + 1/n₂) ]
where p̂_pool = (k₁+k₂)/(n₁+n₂).
Then p-value = 2·Φ(–|z|) (two-sided) or Φ(–z) (one-sided), Φ = normal CDF.
Multiple-comparison correction
You are doing 3 tests, so control false-positive inflation:
• Bonferroni: α_adj = α/3 ➜ need p < 0.05/3 ≈ 0.0167
• Holm or Benjamini-Hochberg controls FWER/FDR in a less conservative way.
────────────────────────────────────────────
4. Optional: “Fancy” but often cleaner approaches
────────────────────────────────────────────
Logistic regression
Fit: conversion ~ 1 + variant_B + variant_C
Overall likelihood-ratio test ➜ same as χ² above.
Individual coefficients’ Wald tests automatically give pairwise comparisons.
Bayesian ABn test
Specify Beta(1,1) (uninformative) priors, update to Beta(kᵢ+1, nᵢ–kᵢ+1).
Compute posterior probability that p_B > p_A, etc.
No p-values, but you get direct probabilities and credible intervals.
────────────────────────────────────────────
5. What to report
────────────────────────────────────────────
• Sample sizes, conversions, observed rates.
• Global χ² statistic, df, p-value.
• For any sig. pair: effect size (rate difference or uplift %), CI, corrected p-value.
• Mention correction method and test type (two-sided or one-sided).
• Power or minimal detectable effect (if you planned the test).
────────────────────────────────────────────
6. Quick worked example
────────────────────────────────────────────
Suppose:
Variant n k p̂
A 5 000 300 6.0 %
B 4 800 312 6.5 %
C 5 100 285 5.6 %
Step 2: χ² = 4.06, df=2, p=0.13 ➜ not significant; stop.
(If it were, run Step 3.)
────────────────────────────────────────────
7. Handy Python / R snippets
────────────────────────────────────────────
Python (SciPy):
import numpy as np, scipy.stats as st
# counts
n = np.array([5000, 4800, 5100])
k = np.array([300, 312, 285])
# global chi-square
p_pool = k.sum()/n.sum()
chi2 = ((k - n*p_pool)**2 / (n*p_pool*(1-p_pool))).sum()
p_global = 1-st.chi2.cdf(chi2, df=2)
# pairwise z-tests with Bonferroni
from itertools import combinations
alpha = 0.05
for i,j in combinations(range(3),2):
p_pool_ij = (k[i]+k[j])/(n[i]+n[j])
z = (k[i]/n[i]-k[j]/n[j]) / np.sqrt(p_pool_ij*(1-p_pool_ij)*(1/n[i]+1/n[j]))
p_pair = 2*(1-st.norm.cdf(abs(z)))
print(i,j,p_pair,"significant?" ,p_pair<alpha/3)
R (built-in):
k <- c(300,312,285)
n <- c(5000,4800,5100)
prop.test(k,n) # global χ²
pairwise.prop.test(k,n,p.adjust.method="bonferroni")
────────────────────────────────────────────
TL;DR
────────────────────────────────────────────
- One χ² test (or Fisher) answers “any difference?”.
- If significant, run three two-proportion z-tests (A-B, A-C, B-C) and adjust for multiple comparisons (Bonferroni, Holm, etc.).
- Report effect sizes and confidence intervals, not just p-values.