TapCub is live — analytics, insights and live chat, free on one platform
Glossary

What Is Sample Size? Definition and Formula with a Worked Example

Sample size is the number of independent observations in a study. For a conversion test it is set by four inputs: baseline, minimum effect, significance level and power. The formula worked by hand for 3.0% → 3.6%, and how n changes as each input moves.

Lucas Hayes Reviewed by Chen Yu Also called sample size Last updated Nov 28, 2026 Glossary

Quick answer

Sample size (n) is the number of independent observations in a study, such as visitors per group in an A/B test. For comparing two conversion rates it is set by four inputs: baseline rate, minimum effect to detect, significance level and power. Halving the effect roughly quadruples n.

Formula: n per group = (z₁₋α/₂ + z₁₋β)² × [p₁(1 − p₁) + p₂(1 − p₂)] ÷ (p₁ − p₂)²; for α = 0.05 two-sided and 80% power, z values are 1.960 and 0.842.

What is sample size?

Sample size is the number of independent observations in a study, written n: the people surveyed, the visitors in each group of an A/B test, the orders in an audit. In a comparison between two groups it is usually quoted per group.

The useful question is not "what is sample size" but "how large must it be?" For a test comparing two conversion rates, the answer comes from four inputs and nothing else:

  1. Baseline rate: the conversion rate you have now.
  2. Minimum effect you want to detect: the smallest change worth acting on.
  3. Significance level (α): the false-positive rate you accept.
  4. Power (1 − β): the chance of detecting the effect if it is real.

Change any one of them and the required n changes, often a lot: halving the effect you want to detect roughly quadruples the sample. The rest of this page gives the formula, works it by hand for a 3.0% → 3.6% test and shows how n moves with each input.

The four inputs that set sample size

InputTypical choiceWhere it comes fromEffect on n
Baseline rate p₁Your current rate, e.g. 3.0%Last 4 weeks of data for the same page and audienceLower baselines need more visitors
Minimum detectable effecte.g. +20% relative (3.0% → 3.6%)The smallest change that would change a decisionHalving it multiplies n by about 4
Significance level α0.05, two-sidedConvention; stricter for high-stakes decisions0.01 instead of 0.05 adds about 49%
Power 1 − β0.80Convention; 0.90 when a miss is costly0.90 instead of 0.80 adds about 34%

The conventions are not arbitrary. The ICH E9 guideline on statistical principles for clinical trials says the type I error is conventionally set at 5% or less and the type II error at 10% to 20%, that is, power of 80% to 90%. The minimum detectable effect and statistical power each have their own page; this one shows how they combine into n.

The sample size formula for comparing two proportions

For two groups of equal size, a two-sided test at level α and power 1 − β:

n per group = (z₁₋α/₂ + z₁₋β)² × [p₁(1 − p₁) + p₂(1 − p₂)] ÷ (p₁ − p₂)²

where p₁ is the baseline rate, p₂ the rate you want to be able to detect, and the z values come from the standard normal distribution:

Settingz value
α = 0.05 two-sided (z₁₋α/₂)1.960
α = 0.05 one-sided (z₁₋α)1.645
α = 0.01 two-sided2.576
Power 80% (z₁₋β)0.842
Power 90%1.282

The NIST/SEMATECH e-Handbook of Statistical Methods gives the closely related form for testing one proportion against a fixed value, with the two standard deviations weighted separately; both forms rest on the same normal approximation.

Worked example: 3.0% to 3.6% by hand

Sample data: a signup page converts 3.0% of visitors. The team wants to detect a lift to 3.6% (+0.6 points, +20% relative), two-sided α = 0.05, power 80%.

  1. Sum of z values: 1.960 + 0.842 = 2.802. Squared: 7.849.
  2. Variance term: 0.030 × 0.970 + 0.036 × 0.964 = 0.02910 + 0.03470 = 0.06380.
  3. Effect squared: (0.036 − 0.030)² = 0.006² = 0.000036.
  4. n per group = 7.849 × 0.06380 ÷ 0.000036 ≈ 13,911 (13,910.8 before rounding up, using unrounded z values).

So the test needs about 13,911 visitors per group, 27,822 in total. If 2,000 eligible visitors reach the page each day, that is 27,822 ÷ 2,000 ≈ 14 days, which conveniently covers two full weekly cycles. If only 500 a day reach it, the same test takes 56 days, and the team should either test a bigger change or pick a page with more traffic.

The 13,911 counts the experimental units the test randomizes, usually visitors, not sessions or pageviews. Counting sessions makes the sample look larger than it is.

How does sample size change with each input?

All rows keep the other inputs from the worked example (baseline 3.0%, two-sided α = 0.05, power 80%) unless the row says otherwise:

ScenarioRate to detectn per groupvs example
+40% relative lift3.0% → 4.2%3,7790.27×
+20% relative lift (example)3.0% → 3.6%13,9111.00×
+10% relative lift3.0% → 3.3%53,2083.82×
+5% relative lift3.0% → 3.15%207,93514.95×
Power 90% instead of 80%3.0% → 3.6%18,6231.34×
α = 0.01 instead of 0.053.0% → 3.6%20,6991.49×
One-sided α = 0.053.0% → 3.6%10,9580.79×
Baseline 6.0%, +20% relative6.0% → 7.2%6,7160.48×
Baseline 1.5%, +20% relative1.5% → 1.8%28,3002.03×

Three rules of thumb follow, each visible in the table:

  • Halving the effect roughly quadruples n. Going from +20% to +10% multiplies n by 3.8; from +10% to +5% by 3.9. The effect enters the formula squared.
  • Halving the baseline roughly doubles n for the same relative lift (1.5% needs 2.0× the visitors of 3.0%).
  • Stricter α and higher power cost less than a smaller effect. Moving to 90% power adds a third; moving to α = 0.01 adds about half.

A one-sided test needs 21% fewer visitors here, but it cannot detect a drop. Decide on one or two tails before the test, not after seeing the data.

Sample size for estimating a single rate

Not every question compares two groups. To test whether a single rate differs from a fixed value, the NIST e-Handbook (section 7.2.4.2) works this example: to detect a change from p₀ = 0.10 to p₁ = 0.20 with a one-sided α = 0.05 (z = 1.645) and power 0.90 (z = 1.282), N ≥ [(1.645 × √(0.1 × 0.9) + 1.282 × √(0.2 × 0.8)) ÷ 0.1]² ≈ 102, or 112 with a continuity correction. The same logic applies: the difference you want to detect sits in the denominator, squared.

Common mistakes with sample size

  • Stopping when the result turns significant. Checking every day and stopping at the first p < 0.05 inflates false positives well above 5%. Fix n in advance and run to it.
  • Confusing relative and absolute effects. "+20%" from 3.0% means 3.6%, not 23%. Write both the relative lift and the target rate.
  • Quoting the total as if it were per group. 13,911 is per group; the test needs 27,822 visitors.
  • Using a baseline from a different audience. A sitewide 3.0% rate for a test that only runs on mobile visitors, who may convert at 2.0%, understates the sample needed.
  • Ignoring traffic that never reaches the tested element. If only 40% of page visitors scroll to the form being tested, the eligible traffic per day is 40% of the page's visitors.

For running the tests themselves, from hypothesis to readout, see CRO testing.

Getting sample size inputs from TapCub

TapCub does not split traffic or calculate sample sizes; it supplies the two inputs that depend on your own data, measured in the right unit:

  1. Read the baseline. In Web analytics › Goals, the goal's conversion rate is distinct visitors who completed it divided by distinct visitors in the range, the per-visitor unit the formula expects. Use four recent weeks, and filter to the page and audience the test will run on.
  2. Estimate daily eligible traffic. Web analytics › Pages shows visitors per page; divide the four-week total by 28 to get the daily figure for the duration estimate (2,000 a day in the example).
  3. Check how many visitors reach the tested element. If the change sits below the fold, All-platform analytics › Behavior › Heatmaps shows scroll depth, so you can discount visitors who never see it.
  4. Keep bots out of the counts. Bots detected by TapCub are counted separately and do not inflate visitor counts or lower the baseline rate.
  5. Mark the test window. Add the start and planned end date in Configuration › Annotations, so nobody reads the results before the planned n is reached.

See also: What is experimental probability? Formula and examples.

See also: Orthogonal array: definition and L4 / L8 examples in experiment design.

Sources

  • NIST/SEMATECH e-Handbook of Statistical Methods. 7.2.4.2 Sample sizes required — sample size formula for a proportion; worked example N ≈ 102, 112 with continuity correction. Checked 2026-11-28.
  • ICH. E9 Statistical Principles for Clinical Trials, Step 4 version dated 5 February 1998, section 3.5 — type I error conventionally 5% or less, type II error 10% to 20%. Checked 2026-11-28.

Was this explanation clear?

We use your answers to fix and expand this page.

Lucas Hayes

Data Engineer

Writes about event design, data quality, and collection workflows, with verifiable implementation methods for reliable analytics.

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What is a good sample size?

One large enough to detect the smallest effect you care about with the power you want. For a 3.0% baseline, detecting a lift to 3.6% at α = 0.05 and 80% power needs about 13,911 visitors per group; detecting 3.3% needs about 53,208. There is no single good number without those inputs.

What are the four factors that determine sample size?

The baseline rate, the minimum effect you want to detect, the significance level α and the statistical power. Smaller effects, lower baselines, stricter α and higher power all increase the required sample, with the effect size mattering most because it enters the formula squared.

Is sample size per group or in total?

For two-group tests the formula gives n per group. The example's 13,911 means 13,911 visitors in control and 13,911 in the variant, 27,822 in total. Always say which one you are quoting, and count the units the test randomizes, usually visitors, not sessions.

How long should an A/B test run to reach its sample size?

Divide the total sample by eligible daily visitors: 27,822 ÷ 2,000 ≈ 14 days in the example. Round up to whole weeks so weekday and weekend behavior are both included, and do not stop early because the result looks significant.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics