Ab Test Conversion Rate Calculator

A/B Test Conversion Rate Calculator

This calculator helps you determine the statistical significance of your A/B test results. By inputting the number of visitors and conversions for each variation, you can understand if the observed difference in conversion rates is likely due to a real effect or just random chance.

function calculateABTestSignificance() { var visitorsA = parseFloat(document.getElementById("visitorsA").value); var conversionsA = parseFloat(document.getElementById("conversionsA").value); var visitorsB = parseFloat(document.getElementById("visitorsB").value); var conversionsB = parseFloat(document.getElementById("conversionsB").value); var resultDiv = document.getElementById("result"); resultDiv.innerHTML = "; // Clear previous results if (isNaN(visitorsA) || isNaN(conversionsA) || isNaN(visitorsB) || isNaN(conversionsB) || visitorsA <= 0 || conversionsA < 0 || visitorsB <= 0 || conversionsB < 0) { resultDiv.innerHTML = 'Please enter valid positive numbers for visitors and non-negative numbers for conversions.'; return; } // Calculate conversion rates var rateA = conversionsA / visitorsA; var rateB = conversionsB / visitorsB; // Calculate pooled proportion var pooledConversions = conversionsA + conversionsB; var pooledVisitors = visitorsA + visitorsB; var pooledRate = pooledConversions / pooledVisitors; // Calculate standard error for each group var seA = Math.sqrt((pooledRate * (1 – pooledRate)) / visitorsA); var seB = Math.sqrt((pooledRate * (1 – pooledRate)) / visitorsB); // Calculate standard error of the difference var seDifference = Math.sqrt(Math.pow(seA, 2) + Math.pow(seB, 2)); // Calculate Z-score var zScore = (rateB – rateA) / seDifference; // Calculate P-value (for a two-tailed test) // This is an approximation using the normal distribution CDF. // For more precision, a Z-table or more complex statistical functions would be used. function normalCDF(x) { var t = 1 / (1 + 0.3275911 * Math.abs(x)); var y = 1 – (((((10614 * t – 132341) * t + 47036) * t – 114606) * t + 40371) * t – 12643) * t * Math.exp(-x * x / 2); if (x < 0) { return y; } else { return 1 – y; } } var pValue = 2 * (1 – normalCDF(Math.abs(zScore))); var htmlOutput = '

Results:

'; htmlOutput += 'Conversion Rate (Control): ' + (rateA * 100).toFixed(2) + '%'; htmlOutput += 'Conversion Rate (Variant): ' + (rateB * 100).toFixed(2) + '%'; htmlOutput += 'Difference in Conversion Rate: ' + ((rateB – rateA) * 100).toFixed(2) + '%'; htmlOutput += 'Z-Score: ' + zScore.toFixed(4) + "; htmlOutput += 'P-value (Two-tailed): ' + pValue.toFixed(4) + "; var significanceLevel = 0.05; // Common significance level (alpha) if (pValue < significanceLevel) { htmlOutput += 'The difference in conversion rates is statistically significant at the ' + (significanceLevel * 100) + '% level.'; } else { htmlOutput += 'The difference in conversion rates is not statistically significant at the ' + (significanceLevel * 100) + '% level. The observed difference could be due to random chance.'; } resultDiv.innerHTML = htmlOutput; } #ab-test-calculator { font-family: sans-serif; max-width: 500px; margin: 20px auto; padding: 20px; border: 1px solid #ccc; border-radius: 8px; background-color: #f9f9f9; } .input-group { margin-bottom: 15px; } .input-group label { display: block; margin-bottom: 5px; font-weight: bold; } .input-group input { width: calc(100% – 12px); padding: 8px; border: 1px solid #ccc; border-radius: 4px; } button { padding: 10px 15px; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; } button:hover { background-color: #45a049; } #result { margin-top: 20px; padding: 15px; border: 1px dashed #ddd; background-color: #fff; border-radius: 4px; } #result h3 { margin-top: 0; }

Leave a Comment