Confidence Interval for a Proportion: Analysing Add-to-Cart Rate

statistics
A/B testing
conversion optimization
web analytics
Estimate the add to cart rate with a 95% confidence interval, read the margin of error and decide if KPIs are acceptable. Runnable R/WebR code.
Published

June 10, 2024

Keywords

confidence interval, margin of error, binomial proportion, ecommerce, A/B testing

TL;DR: Add-to-cart is 22% (n=600), 95% CI [18.7%, 25.3%]. The observed rate is above the 19% baseline KPI, and the interval still includes 19%, so this sample leaves the baseline open. The stretch goal of 26% is out of reach. For ±2 pp precision, plan for 1,648 to 2,401 visitors.

Answer
Method: Wald confidence interval for a proportion.
Estimate: 22% and CI 18.7%, 25.3%.
Data: E-commerce traffic, variables add_to_cart, n = 600.
Action: Collect more visitors before declaring the baseline KPI (19%) met. The stretch goal (26%) is out of reach.

Case

You are a data analyst for an e-commerce site. You observed a 22% add-to-cart rate over two weeks with 600 visitors. The business question: Does this performance meet the baseline KPI of 19%? Can you claim the stretch goal of 26%? To answer this, you need to compute a 95% confidence interval for the add-to-cart proportion, read the margin of error and assess whether the KPIs are acceptable.

Dataset

Synthetic sample for a single two-week window.

Variable Label Value
successes Add to cart count 132
n Sample size 600
p_hat Observed proportion 0.22

Method

We use the Wald large-sample CI for a binomial proportion (Agresti 2019):

\[ \text{MOE} = Z^* \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}. \]

Calculation

Visualisation

Results and Interpretation

The estimated add-to-cart proportion was 0.22 (22.0%) with a 95% confidence interval of [0.187, 0.253] (or [18.7%, 25.3%]), a margin of error of ±3.3 percentage points. The large-sample rule holds (132 successes, 468 failures) (Agresti 2019; R Core Team 2024).

KPI assessment. Baseline KPI (19%) lies within the CI, and stretch KPI (26%) lies above it.

Business decision. The observed rate is above 19%, while the 95% confidence interval includes 19%, so this sample does not establish that the underlying rate exceeds the baseline. Claiming the stretch KPI (26%) needs more visitors or better performance.

Sample Size Planning

To achieve ±2 percentage points precision at 95% confidence: \[ n = \hat{p}(1-\hat{p})\left(\frac{Z^*}{\text{MOE}_{\text{target}}}\right)^2. \]

Assumptions

The Wald interval assumes:

  • Independent observations: Each visitor’s cart action is independent (no clustering by session or user ID)
  • Random sampling: Visitors represent a random sample from the population, spread evenly across traffic sources and times
  • Large-sample validity: Both \(n\hat{p} \ge 10\) and \(n(1-\hat{p}) \ge 10\) (conditions met: 132 successes and 468 failures both exceed 10)
  • Choice of interval: Wald is the textbook formula and is serviceable at this sample size. The Wilson interval keeps closer to its stated 95% coverage near 0% or 100% and at small n, so it is the better general default. Here it gives 18.9% to 25.5%, which leads to the same reading of both KPIs. In R, prop.test(132, 600, correct = FALSE)$conf.int returns it.
  • Stable process: The true conversion rate remains constant during the observation period (no seasonal trends, promotional effects or A/B tests running concurrently)

Use the below format to cite this page

Sharafuddin, M. A. (2024, June 10). Confidence interval for a proportion: Analysing add-to-cart rate. Flair Marketing Intelligence (FlairMI). https://flairmi.com/blog/posts/01-margin-of-error.html
@online{sharafuddin2024-ci-proportion,
  author = {Sharafuddin, Mohammed Ali},
  title  = {Confidence Interval for a Proportion: Analysing Add-to-Cart Rate},
  year   = {2024},
  date   = {2024-06-10},
  url    = {https://flairmi.com/blog/posts/01-margin-of-error.html},
  langid = {en}
}

Try it in the browser

Margins of error for proportions are built into two free browser tools: the A/B Test Calculator, which draws a confidence interval for each group, and the Net Promoter Score Tracker, which reports the margin of error for every survey wave. Both belong to the Marketing Toolkit Hub.

Comments

References

Agresti, Alan. 2019. Statistical Methods for the Social Sciences. Boston, MA: Pearson.
R Core Team. 2024. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.r-project.org/.

Citation

BibTeX citation:
@online{ali_sharafuddin2024,
  author = {Ali Sharafuddin, Mohammed},
  title = {Confidence {Interval} for a {Proportion:} {Analysing}
    {Add-to-Cart} {Rate}},
  date = {2024-06-10},
  url = {https://flairmi.com/blog/posts/01-margin-of-error.html},
  langid = {en}
}
For attribution, please cite this work as:
Ali Sharafuddin, Mohammed. 2024. “Confidence Interval for a Proportion: Analysing Add-to-Cart Rate.” June 10, 2024. https://flairmi.com/blog/posts/01-margin-of-error.html.