Calculating Nps Score

NPS Score Calculator: Measure Customer Loyalty :root { –primary-color: #004a99; –success-color: #28a745; –background-color: #f8f9fa; –text-color: #333; –border-color: #ddd; –card-background: #fff; –error-color: #dc3545; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(–background-color); color: var(–text-color); margin: 0; padding: 0; line-height: 1.6; } .container { max-width: 960px; margin: 20px auto; padding: 20px; background-color: var(–card-background); border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column; align-items: center; } header { text-align: center; margin-bottom: 30px; width: 100%; } h1 { color: var(–primary-color); margin-bottom: 10px; } .subtitle { font-size: 1.1em; color: #555; margin-bottom: 20px; } .loan-calc-container { width: 100%; max-width: 600px; margin-bottom: 30px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–card-background); box-shadow: 0 1px 5px rgba(0,0,0,0.05); } .input-group { margin-bottom: 20px; width: 100%; text-align: left; } .input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: var(–primary-color); } .input-group input[type="number"], .input-group select { width: calc(100% – 20px); padding: 12px 10px; border: 1px solid var(–border-color); border-radius: 4px; font-size: 1em; box-sizing: border-box; transition: border-color 0.2s ease-in-out; } .input-group input[type="number"]:focus, .input-group select:focus { outline: none; border-color: var(–primary-color); box-shadow: 0 0 0 2px rgba(0, 74, 153, 0.2); } .input-group .helper-text { font-size: 0.85em; color: #666; margin-top: 5px; display: block; } .error-message { color: var(–error-color); font-size: 0.85em; margin-top: 5px; min-height: 1.1em; } .button-group { display: flex; gap: 10px; margin-top: 20px; justify-content: center; } button { padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; font-size: 1em; font-weight: bold; transition: background-color 0.2s ease-in-out, transform 0.1s ease; color: white; } button:hover { opacity: 0.9; } button:active { transform: translateY(1px); } .btn-primary { background-color: var(–primary-color); } .btn-success { background-color: var(–success-color); } .btn-secondary { background-color: #6c757d; } #results-container { margin-top: 30px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–card-background); width: 100%; max-width: 600px; box-shadow: 0 1px 5px rgba(0,0,0,0.05); text-align: center; } #results-container h2 { color: var(–primary-color); margin-bottom: 15px; } .nps-result { font-size: 2.5em; font-weight: bold; color: var(–primary-color); background-color: #e7f3ff; padding: 15px 20px; border-radius: 5px; display: inline-block; margin-bottom: 15px; min-width: 100px; } .intermediate-results { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 15px; margin-bottom: 20px; font-size: 0.95em; } .intermediate-results div { text-align: center; padding: 10px; border-radius: 4px; background-color: #f0f0f0; flex: 1; min-width: 120px; } .intermediate-results span { font-weight: bold; display: block; font-size: 1.2em; color: var(–primary-color); } .formula-explanation { font-size: 0.9em; color: #555; margin-top: 10px; border-top: 1px dashed #eee; padding-top: 10px; } .chart-container { margin-top: 30px; width: 100%; max-width: 600px; background-color: var(–card-background); padding: 25px; border-radius: 8px; border: 1px solid var(–border-color); box-shadow: 0 1px 5px rgba(0,0,0,0.05); } .chart-container h2 { color: var(–primary-color); margin-bottom: 15px; text-align: center; } caption { font-size: 0.9em; color: #666; margin-bottom: 10px; text-align: center; } table { width: 100%; border-collapse: collapse; margin-bottom: 20px; } th, td { padding: 10px 12px; border: 1px solid #eee; text-align: right; } th { background-color: #f8f8f8; font-weight: bold; text-align: center; color: var(–primary-color); } td:first-child { text-align: left; } .article-content { margin-top: 40px; width: 100%; max-width: 960px; padding: 20px; background-color: var(–card-background); border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } .article-content h2, .article-content h3 { color: var(–primary-color); margin-top: 25px; margin-bottom: 15px; } .article-content h3 { margin-top: 20px; margin-bottom: 10px; font-size: 1.3em; } .article-content p { margin-bottom: 15px; } .article-content ul, .article-content ol { margin-left: 20px; margin-bottom: 15px; } .article-content li { margin-bottom: 8px; } .faq-item { margin-bottom: 15px; } .faq-item h4 { color: var(–primary-color); margin-bottom: 5px; cursor: pointer; font-size: 1.1em; } .faq-item p { margin-left: 15px; display: none; /* Hidden by default */ color: #444; font-size: 0.95em; } .faq-item.open p { display: block; } .internal-links { margin-top: 30px; padding: 20px; background-color: var(–card-background); border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } .internal-links h3 { color: var(–primary-color); margin-bottom: 15px; text-align: center; } .internal-links ul { list-style: none; padding: 0; margin: 0; text-align: center; } .internal-links li { margin-bottom: 10px; } .internal-links a { color: var(–primary-color); text-decoration: none; font-weight: bold; } .internal-links a:hover { text-decoration: underline; } .internal-links p { font-size: 0.9em; color: #555; margin-left: 10px; display: block; } .key-assumption { font-size: 0.9em; color: #666; margin-top: 15px; text-align: center; border-top: 1px dashed #eee; padding-top: 10px; }

NPS Score Calculator

Measure your customer loyalty and identify promoters, passives, and detractors.

Customers who gave a score of 9 or 10.
Customers who gave a score of 7 or 8.
Customers who gave a score of 0 to 6.

NPS Results

Promoters
Passives
Detractors
Formula: NPS = (% Promoters – % Detractors)
Key Assumption: Total respondents = Promoters + Passives + Detractors

Response Distribution

Distribution of customer feedback scores (Promoters, Passives, Detractors).

NPS Over Time (Hypothetical)

Illustrative NPS trend based on hypothetical data.
Summary of Customer Feedback
Category Count Percentage
Promoters (9-10)
Passives (7-8)
Detractors (0-6)
Total Respondents 100%

What is NPS Score?

The NPS score, or Net Promoter Score, is a crucial metric used to gauge customer loyalty and satisfaction. Developed by Bain & Company, it's a simple yet powerful tool that helps businesses understand how likely their customers are to recommend their products or services to others. This score is derived from a single question: "On a scale of 0 to 10, how likely are you to recommend [company/product/service] to a friend or colleague?"

Businesses across all industries leverage the NPS score because it provides a clear indicator of customer sentiment and predicts business growth. A high NPS score suggests a strong customer base that is likely to be loyal, make repeat purchases, and act as brand advocates. Conversely, a low score signals potential issues with customer experience that need urgent attention.

Who Should Use NPS?

Virtually any organization that interacts with customers can benefit from calculating and tracking their NPS score. This includes:

  • SaaS companies and software providers
  • Retail businesses (online and brick-and-mortar)
  • Service-based industries (consulting, agencies, hospitality)
  • Financial institutions and banks
  • Telecommunications companies
  • Healthcare providers
  • Any business focused on customer retention and growth.

By understanding customer loyalty, businesses can make informed decisions about product development, customer service improvements, marketing strategies, and overall business direction. The NPS score serves as a universal language for customer advocacy.

Common Misconceptions about NPS

Despite its widespread use, some common misconceptions surround the NPS score:

  • NPS is just a number: While the score itself is a number, its true value lies in the qualitative feedback that often accompanies it, providing context and actionable insights.
  • NPS is only about satisfaction: NPS measures willingness to recommend, which is a stronger indicator of loyalty and advocacy than mere satisfaction. A satisfied customer might not necessarily recommend.
  • NPS should be compared across industries: NPS benchmarks are most meaningful within your specific industry or peer group. Comparing your NPS to a completely different sector can be misleading.
  • A negative NPS is always bad: A negative NPS score simply indicates more detractors than promoters. It's a starting point for improvement, not necessarily a failure. Many successful companies have negative NPS.

NPS Score Formula and Mathematical Explanation

The Net Promoter Score (NPS) calculation is straightforward, focusing on the proportion of customers who are likely to recommend your brand versus those who are not.

Step-by-step derivation:

  1. Categorize Respondents: Based on their score (0-10), customers are divided into three groups:
    • Promoters: Scored 9 or 10. These are your loyal enthusiasts who will keep buying and refer others.
    • Passives: Scored 7 or 8. These are satisfied but unenthusiastic customers who are vulnerable to competitive offerings.
    • Detractors: Scored 0 to 6. These are unhappy customers who can damage your brand and impede growth through negative word-of-mouth.
  2. Calculate Percentages: Determine the percentage of total respondents for each category.
    • % Promoters = (Number of Promoters / Total Number of Respondents) * 100
    • % Passives = (Number of Passives / Total Number of Respondents) * 100
    • % Detractors = (Number of Detractors / Total Number of Respondents) * 100
    • Total Number of Respondents = Number of Promoters + Number of Passives + Number of Detractors
  3. Calculate NPS: Subtract the percentage of Detractors from the percentage of Promoters.
    • NPS = % Promoters – % Detractors

The resulting NPS score ranges from -100 (if every customer is a detractor) to +100 (if every customer is a promoter). The score is presented as a whole number without a percentage sign.

Variable Explanations:

Variable Meaning Unit Typical Range
Number of Promoters Count of customers who gave a score of 9 or 10. Count ≥ 0
Number of Passives Count of customers who gave a score of 7 or 8. Count ≥ 0
Number of Detractors Count of customers who gave a score of 0 to 6. Count ≥ 0
Total Respondents Sum of Promoters, Passives, and Detractors. Count ≥ 0
% Promoters Percentage of total respondents who are promoters. Percentage (%) 0% to 100%
% Passives Percentage of total respondents who are passives. Percentage (%) 0% to 100%
% Detractors Percentage of total respondents who are detractors. Percentage (%) 0% to 100%
NPS Score Net Promoter Score calculated as % Promoters – % Detractors. Score (integer) -100 to +100

Practical Examples (Real-World Use Cases)

Example 1: E-commerce Retailer

An online clothing store surveys its recent customers about their shopping experience.

  • Inputs:
  • Number of Promoters (Score 9-10): 150
  • Number of Passives (Score 7-8): 40
  • Number of Detractors (Score 0-6): 10

Calculation:

  • Total Respondents = 150 + 40 + 10 = 200
  • % Promoters = (150 / 200) * 100 = 75%
  • % Detractors = (10 / 200) * 100 = 5%
  • NPS Score = 75% – 5% = 70

Interpretation: An NPS of 70 is considered excellent. This e-commerce retailer has a strong base of loyal customers who are likely recommending the brand. The high number of promoters indicates a positive customer experience and effective business operations.

Example 2: Software as a Service (SaaS) Company

A SaaS provider sends out its quarterly NPS survey to its user base.

  • Inputs:
  • Number of Promoters (Score 9-10): 220
  • Number of Passives (Score 7-8): 350
  • Number of Detractors (Score 0-6): 130

Calculation:

  • Total Respondents = 220 + 350 + 130 = 700
  • % Promoters = (220 / 700) * 100 ≈ 31.4%
  • % Detractors = (130 / 700) * 100 ≈ 18.6%
  • NPS Score = 31.4% – 18.6% = 12.8 ≈ 13

Interpretation: An NPS of 13 is considered fair to good, depending on industry benchmarks. While the company has a solid number of promoters, the significant number of passives suggests an opportunity to convert them into promoters through enhanced engagement and product value. Addressing the concerns of detractors is also crucial to prevent churn and negative reviews.

How to Use This NPS Score Calculator

Our NPS Score Calculator is designed for simplicity and accuracy. Follow these steps to get your customer loyalty score:

  1. Gather Your Data: Collect the results from your customer feedback survey. You need the total count of customers who responded within each category: Promoters (score 9-10), Passives (score 7-8), and Detractors (score 0-6).
  2. Enter the Numbers: Input the exact counts for Promoters, Passives, and Detractors into the respective fields in the calculator.
  3. Click Calculate: Press the "Calculate NPS" button. The calculator will instantly display your NPS score, the number of customers in each category, and their respective percentages.
  4. Review the Results: Your NPS score will be prominently displayed. The intermediate results show the breakdown of your customer base by loyalty category. The table provides a detailed view of the counts and percentages.
  5. Interpret Your Score: Understand what your NPS score means. Scores above 0 are generally considered good, while scores above 50 are excellent. However, always compare your score against industry benchmarks and your own historical data.
  6. Utilize the Data: Use the NPS score and the distribution percentages to inform your business strategy. Focus on converting passives and understanding the reasons behind detractors' feedback to improve customer experience.

Decision-Making Guidance:

  • High NPS (e.g., 50+): Celebrate your success! Continue delivering excellent experiences and leverage your promoters for testimonials and referrals.
  • Moderate NPS (e.g., 0-49): Focus on strategies to increase promoters and decrease detractors. Analyze feedback for areas of improvement.
  • Low NPS (e.g., below 0): Urgent action is needed. Prioritize understanding and addressing the issues that lead to detraction. Engage with unhappy customers to resolve their problems.

Use the "Reset" button to clear the fields and perform new calculations. The "Copy Results" button allows you to easily share your findings.

Key Factors That Affect NPS Results

Several factors can influence your NPS score and its interpretation:

  1. Product/Service Quality: The core performance and reliability of your offering are paramount. A high-quality product or service naturally leads to more promoters.
  2. Customer Service Experience: How your support teams interact with customers significantly impacts loyalty. Responsive, empathetic, and effective support turns potentially negative experiences into positive ones, influencing NPS.
  3. Ease of Use/User Experience (UX): For software or digital products, a simple, intuitive, and frustration-free user experience is critical. Complex or confusing interfaces can generate detractors.
  4. Value for Money: Customers assess whether the benefits they receive align with the price they pay. Perceived high value can increase promoters, while perceived low value can create detractors.
  5. Brand Reputation and Trust: A company's overall reputation, ethical practices, and trustworthiness play a role. Negative news or scandals can erode customer loyalty and negatively impact NPS.
  6. Onboarding Process: For services or software, a smooth and effective onboarding process sets the stage for the customer relationship. A poor onboarding experience can lead to early dissatisfaction and detraction.
  7. Communication and Transparency: Keeping customers informed about updates, issues, or changes builds trust. Lack of transparency or poor communication can lead to frustration and detractors.
  8. Competitive Landscape: The availability and quality of competing offerings influence customer perception. If competitors offer superior value or experience, it can make your customers more likely to become passives or detractors.

Frequently Asked Questions (FAQ)

What is the ideal NPS score?

While there's no universal "ideal" score, scores above 0 are generally considered good. Scores above 50 are typically excellent, and scores above 70 are world-class. However, the most important benchmark is your own industry average and your historical NPS trend.

Can my NPS score be negative?

Yes, your NPS score can be negative. This occurs when the percentage of Detractors is higher than the percentage of Promoters. A negative score indicates that you have more unhappy customers than happy ones, signaling a critical need for improvement.

What's the difference between NPS and customer satisfaction (CSAT)?

NPS measures the likelihood to recommend, predicting loyalty and growth. CSAT measures satisfaction with a specific interaction or product feature. While related, NPS is a broader indicator of overall customer relationship health.

How often should I measure NPS?

The frequency depends on your business model. Many businesses measure quarterly or semi-annually. Transactional NPS (measuring after specific interactions) can be done more frequently. Consistency is key for tracking trends.

What if I have very few respondents?

With a small sample size, your NPS score might not be statistically representative. Ensure you collect feedback from a sufficiently large and diverse group of customers for reliable results. Our calculator works regardless of sample size, but interpretation requires context.

Should I ask the follow-up NPS question ("What is the reason for your score?")?

Absolutely. The follow-up question is crucial for understanding the 'why' behind the score. Analyzing the qualitative feedback from promoters, passives, and detractors provides actionable insights for improvement.

How do I improve my NPS score?

Improving NPS involves a holistic approach: enhance product quality, elevate customer service, streamline user experience, actively listen to feedback (especially from detractors), close the loop with customers by acting on their suggestions, and empower your teams to deliver exceptional experiences.

Can NPS be used for B2B vs. B2C?

Yes, NPS is applicable in both B2B and B2C contexts. In B2B, it measures the loyalty of business clients, who often have significant impacts on revenue. The core principle remains the same: assessing the likelihood to recommend.

What are the limitations of NPS?

NPS can be influenced by survey fatigue, cultural differences in rating scales, and may not capture all nuances of customer experience. It's best used in conjunction with other customer feedback metrics and qualitative data.

© 2023 Your Company Name. All rights reserved.

var promotersInput = document.getElementById('promoters'); var passivesInput = document.getElementById('passives'); var detractorsInput = document.getElementById('detractors'); var promotersError = document.getElementById('promoters-error'); var passivesError = document.getElementById('passives-error'); var detractorsError = document.getElementById('detractors-error'); var npsScoreDisplay = document.getElementById('nps-score-display'); var promotersDisplay = document.getElementById('promoters-val'); var passivesDisplay = document.getElementById('passives-val'); var detractorsDisplay = document.getElementById('detractors-val'); var tablePromoters = document.getElementById('table-promoters'); var tablePassives = document.getElementById('table-passives'); var tableDetractors = document.getElementById('table-detractors'); var tablePromotersPercent = document.getElementById('table-promoters-percent'); var tablePassivesPercent = document.getElementById('table-passives-percent'); var tableDetractorsPercent = document.getElementById('table-detractors-percent'); var tableTotal = document.getElementById('table-total'); var npsChartCanvas = document.getElementById('npsChart'); var npsSvgChart = document.getElementById('npsSvgChart'); var npsChartInstance = null; var npsSvgGroup = null; function clearErrors() { promotersError.textContent = "; passivesError.textContent = "; detractorsError.textContent = "; promotersInput.style.borderColor = "; passivesInput.style.borderColor = "; detractorsInput.style.borderColor = "; } function validateInput(inputElement, errorElement) { var value = parseFloat(inputElement.value); if (isNaN(value) || value 0 ? (p / total) * 100 : 0; var paPercent = total > 0 ? (pa / total) * 100 : 0; var dPercent = total > 0 ? (d / total) * 100 : 0; // Update Canvas Chart if (npsChartInstance) { npsChartInstance.data.datasets[0].data = [pPercent, paPercent, dPercent]; npsChartInstance.update(); } else { var ctx = npsChartCanvas.getContext('2d'); npsChartInstance = new Chart(ctx, { type: 'bar', data: { labels: ['Promoters', 'Passives', 'Detractors'], datasets: [{ label: 'Percentage of Respondents', data: [pPercent, paPercent, dPercent], backgroundColor: [ 'rgba(40, 167, 69, 0.7)', // Green for Promoters 'rgba(255, 193, 7, 0.7)', // Yellow for Passives 'rgba(220, 53, 69, 0.7)' // Red for Detractors ], borderColor: [ 'rgba(40, 167, 69, 1)', 'rgba(255, 193, 7, 1)', 'rgba(220, 53, 69, 1)' ], borderWidth: 1 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, ticks: { callback: function(value) { return value + '%'; } } } }, plugins: { legend: { display: false }, tooltip: { callbacks: { label: function(context) { var label = context.dataset.label || "; if (label) { label += ': '; } if (context.parsed.y !== null) { label += context.parsed.y + '%'; } return label; } } } } } }); } // Update SVG Chart (Hypothetical NPS over Time) // Clear previous elements if (npsSvgGroup) { npsSvgGroup.remove(); } npsSvgGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); npsSvgChart.appendChild(npsSvgGroup); // Hypothetical data for SVG chart (e.g., NPS over last 4 quarters) var hypotheticalNpsData = [13, 15, 12, 18]; var chartWidth = parseFloat(npsSvgChart.getAttribute('viewBox').split(' ')[2]); var chartHeight = parseFloat(npsSvgChart.getAttribute('viewBox').split(' ')[3]); var barWidth = (chartWidth – 40) / hypotheticalNpsData.length * 0.6; var barGap = (chartWidth – 40) / hypotheticalNpsData.length * 0.4; var maxNps = 100; var minNps = -100; var chartRange = maxNps – minNps; var zeroLineY = chartHeight * (maxNps / chartRange); var scaleFactor = (chartHeight – 20) / chartRange; // 10px padding top/bottom // Draw Zero Line var zeroLine = document.createElementNS('http://www.w3.org/2000/svg', 'line'); zeroLine.setAttribute('x1′, '20'); zeroLine.setAttribute('y1', zeroLineY); zeroLine.setAttribute('x2', chartWidth – 20); zeroLine.setAttribute('y2', zeroLineY); zeroLine.setAttribute('stroke', '#ccc'); zeroLine.setAttribute('stroke-width', '1'); zeroLine.setAttribute('stroke-dasharray', '5,5'); npsSvgGroup.appendChild(zeroLine); // Draw Bars and Labels hypotheticalNpsData.forEach(function(npsValue, index) { var barHeight = Math.abs(npsValue) * scaleFactor; var barY = npsValue >= 0 ? zeroLineY – barHeight : zeroLineY; var barX = 20 + (barWidth + barGap) * index + barGap / 2; var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); rect.setAttribute('x', barX); rect.setAttribute('y', barY); rect.setAttribute('width', barWidth); rect.setAttribute('height', barHeight); rect.setAttribute('fill', npsValue >= 0 ? 'var(–primary-color)' : 'var(–error-color)'); npsSvgGroup.appendChild(rect); // Add NPS value label var textLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text'); textLabel.setAttribute('x', barX + barWidth / 2); textLabel.setAttribute('y', npsValue >= 0 ? barY – 5 : chartHeight – 10); textLabel.setAttribute('text-anchor', 'middle'); textLabel.setAttribute('font-size', '12'); textLabel.setAttribute('fill', npsValue >= 0 ? '#000' : '#000'); textLabel.textContent = npsValue.toFixed(0); npsSvgGroup.appendChild(textLabel); // Add X-axis label (e.g., Q1, Q2) var xAxisLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text'); xAxisLabel.setAttribute('x', barX + barWidth / 2); xAxisLabel.setAttribute('y', chartHeight – 5); xAxisLabel.setAttribute('text-anchor', 'middle'); xAxisLabel.setAttribute('font-size', '10'); xAxisLabel.setAttribute('fill', '#555'); xAxisLabel.textContent = 'Q' + (index + 1); npsSvgGroup.appendChild(xAxisLabel); }); // Add a legend for the SVG chart var legendX = 20; var legendY = 15; var legendItemWidth = 15; var legendItemHeight = 10; var legendSpacing = 5; var legendTextOffset = legendItemWidth + legendSpacing; // Promoter Legend var legendPromoterRect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); legendPromoterRect.setAttribute('x', legendX); legendPromoterRect.setAttribute('y', legendY); legendPromoterRect.setAttribute('width', legendItemWidth); legendPromoterRect.setAttribute('height', legendItemHeight); legendPromoterRect.setAttribute('fill', 'var(–primary-color)'); npsSvgGroup.appendChild(legendPromoterRect); var legendPromoterText = document.createElementNS('http://www.w3.org/2000/svg', 'text'); legendPromoterText.setAttribute('x', legendX + legendTextOffset); legendPromoterText.setAttribute('y', legendY + legendItemHeight); legendPromoterText.setAttribute('font-size', '10'); legendPromoterText.setAttribute('fill', '#333'); legendPromoterText.textContent = 'Promoters'; npsSvgGroup.appendChild(legendPromoterText); // Detractor Legend var legendDetractorRect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); legendDetractorRect.setAttribute('x', legendX); legendDetractorRect.setAttribute('y', legendY + legendItemHeight + legendSpacing); legendDetractorRect.setAttribute('width', legendItemWidth); legendDetractorRect.setAttribute('height', legendItemHeight); legendDetractorRect.setAttribute('fill', 'var(–error-color)'); npsSvgGroup.appendChild(legendDetractorRect); var legendDetractorText = document.createElementNS('http://www.w3.org/2000/svg', 'text'); legendDetractorText.setAttribute('x', legendX + legendTextOffset); legendDetractorText.setAttribute('y', legendY + legendItemHeight + legendSpacing + legendItemHeight); legendDetractorText.setAttribute('font-size', '10'); legendDetractorText.setAttribute('fill', '#333'); legendDetractorText.textContent = 'Detractors'; npsSvgGroup.appendChild(legendDetractorText); // Show SVG chart and hide canvas if needed, or manage visibility based on context npsSvgChart.style.display = 'block'; } function resetCalculator() { promotersInput.value = 80; passivesInput.value = 15; detractorsInput.value = 5; calculateNPS(); } function copyResults() { var promoterCount = promotersInput.value; var passiveCount = passivesInput.value; var detractorCount = detractorsInput.value; var npsResult = npsScoreDisplay.textContent; var promotersVal = promotersDisplay.textContent; var passivesVal = passivesDisplay.textContent; var detractorsVal = detractorsDisplay.textContent; var promotersPerc = tablePromotersPercent.textContent; var passivesPerc = tablePassivesPercent.textContent; var detractorsPerc = tableDetractorsPercent.textContent; var totalRespondents = tableTotal.textContent; var resultText = "NPS Score Calculation:\n\n"; resultText += "Inputs:\n"; resultText += "- Promoters: " + promoterCount + "\n"; resultText += "- Passives: " + passiveCount + "\n"; resultText += "- Detractors: " + detractorCount + "\n\n"; resultText += "Results:\n"; resultText += "- NPS Score: " + npsResult + "\n"; resultText += "- Promoters: " + promotersVal + " (" + promotersPerc + ")\n"; resultText += "- Passives: " + passivesVal + " (" + passivesPerc + ")\n"; resultText += "- Detractors: " + detractorsVal + " (" + detractorsPerc + ")\n"; resultText += "- Total Respondents: " + totalRespondents + "\n\n"; resultText += "Formula: NPS = % Promoters – % Detractors\n"; resultText += "Key Assumption: Total respondents = Promoters + Passives + Detractors\n"; var textArea = document.createElement("textarea"); textArea.value = resultText; document.body.appendChild(textArea); textArea.select(); try { document.execCommand('copy'); alert("Results copied to clipboard!"); } catch (err) { alert("Failed to copy results."); } document.body.removeChild(textArea); } function toggleFaq(element) { var faqItem = element.closest('.faq-item'); faqItem.classList.toggle('open'); } // Initial calculation on page load document.addEventListener('DOMContentLoaded', function() { calculateNPS(); // Load Chart.js if not present, or ensure it's available if (typeof Chart === 'undefined') { var script = document.createElement('script'); script.src = 'https://cdn.jsdelivr.net/npm/chart.js'; script.onload = function() { calculateNPS(); // Recalculate after chart library loads }; document.head.appendChild(script); } });

Leave a Comment