function calculateRetention() {
// Get input values
var startInput = document.getElementById('customersStart');
var endInput = document.getElementById('customersEnd');
var newInput = document.getElementById('customersNew');
var resultArea = document.getElementById('resultArea');
var errorMsg = document.getElementById('errorMsg');
var start = parseFloat(startInput.value);
var end = parseFloat(endInput.value);
var newCust = parseFloat(newInput.value);
// Reset display
errorMsg.style.display = 'none';
resultArea.style.display = 'none';
// Validation logic
if (isNaN(start) || isNaN(end) || isNaN(newCust)) {
errorMsg.innerText = "Please enter valid numbers for all fields.";
errorMsg.style.display = 'block';
return;
}
if (start <= 0) {
errorMsg.innerText = "Customers at Start (S) must be greater than 0.";
errorMsg.style.display = 'block';
return;
}
if (newCust < 0 || end < 0) {
errorMsg.innerText = "Customer counts cannot be negative.";
errorMsg.style.display = 'block';
return;
}
// Logic check: End count cannot be less than new customers (implies negative existing customers)
if (end start) {
errorMsg.innerText = "Data Error: You cannot have more retained customers than you started with. Check your 'End' or 'New' inputs.";
errorMsg.style.display = 'block';
return;
}
var retentionRate = (existingRetained / start) * 100;
var churnRate = 100 – retentionRate;
var customersLost = start – existingRetained;
// Update DOM
document.getElementById('crrResult').innerText = retentionRate.toFixed(2) + "%";
document.getElementById('churnResult').innerText = churnRate.toFixed(2) + "%";
document.getElementById('retainedResult').innerText = existingRetained.toLocaleString();
document.getElementById('lostResult').innerText = customersLost.toLocaleString();
resultArea.style.display = 'block';
}
How to Calculate Retention Rates
Customer Retention Rate (CRR) is a critical metric for businesses looking to understand customer loyalty and the long-term health of their revenue streams. Unlike user acquisition, which focuses on growth, retention focuses on keeping the customers you have already worked hard to acquire.
The Customer Retention Rate Formula
To calculate your retention rate accurately, you need to look at a specific period of time (e.g., a month, a quarter, or a year) and exclude any new customers acquired during that specific window. This ensures you are measuring the loyalty of the existing cohort.
CRR = [ ( E – N ) / S ] × 100
Where:
E (End): Total number of customers at the end of the time period.
N (New): Number of new customers acquired during the time period.
S (Start): Number of customers at the start of the time period.
Step-by-Step Calculation Example
Let's assume you want to calculate the retention rate for the first quarter (Q1). Here is a realistic scenario:
Identify Start Customers (S): On January 1st, you had 200 active customers.
Identify End Customers (E): On March 31st, you had 220 active customers.
Identify New Customers (N): During Q1, you signed up 40 new customers.
Now, apply the formula:
First, subtract New customers from End customers: 220 – 40 = 180. This number represents the customers you kept.
Next, divide that number by the Start customers: 180 / 200 = 0.9.
Finally, multiply by 100 to get the percentage: 0.9 × 100 = 90%.
Your Customer Retention Rate for Q1 is 90%. Consequently, your Churn Rate is 10%.
Why Calculating Retention Matters
1. Cost Efficiency
Acquiring a new customer can cost 5 to 25 times more than retaining an existing one. High retention rates indicate that your business is growing efficiently without burning excessive cash on marketing.
2. Customer Lifetime Value (CLV)
Retention directly impacts LTV. The longer a customer stays, the more value they generate. A small increase in retention (e.g., 5%) can lead to a significant increase in profits (25% to 95%).
3. Product/Market Fit Indicator
If your retention rate is low, it suggests that while your marketing might be working (bringing people in), your product or service isn't delivering enough value to make them stay. This is a signal to investigate your onboarding process, customer support, or product features.
What is a Good Retention Rate?
Benchmarks vary significantly by industry. For SaaS companies, a retention rate above 90% annually is often considered excellent. For e-commerce, retention rates are typically lower due to the transactional nature of the business, often hovering around 30-40%. However, the most important benchmark is your own historical data; aim to improve your retention rate quarter over quarter.