02. Customer Satisfaction Metrics Analysis (NPS & CSAT)
1. Overview and Scenario
Situation: We’re working hard to process tickets, but we don’t actually know if customers are satisfied. The CEO asks in a meeting:
“How many people would recommend our service? (NPS)” “Are there any complaints from people who received support? (CSAT)”
In this chapter, we’ll directly calculate and analyze two key metrics: NPS (Net Promoter Score) and CSAT (Customer Satisfaction Score).
2. Data Preparation
This time we’ll use a new table called survey_cs_dummy.
BigQuery (SQL)
# BigQuery connection setup (same as 01. CS Ticket Exploration)
from google.cloud import bigquery
client = bigquery.Client()Data Structure
Key columns of the survey_cs_dummy table:
user_id: Customer IDnps_score: 0-10 points (likelihood to recommend to a friend)csat_score: 1-5 points (support satisfaction)related_ticket_id: Related ticket ID (may not exist)
3. NPS (Net Promoter Score) Analysis
NPS is the most powerful metric for measuring customer loyalty. The formula is as follows:
NPS = (Promoter %) - (Detractor %)
- Promoter: 9-10 points
- Passive: 7-8 points
- Detractor: 0-6 points
❓ Problem 1: Classify Groups
Q. Classify customers into Promoter, Passive, and Detractor based on nps_score, and calculate the ratio of each group.
BigQuery (SQL)
Hint: Use CASE WHEN statement to create an nps_category column.
View Solution
WITH nps_classification AS (
SELECT
nps_score,
CASE
WHEN nps_score >= 9 THEN 'Promoter'
WHEN nps_score >= 7 THEN 'Passive'
ELSE 'Detractor'
END as nps_category
FROM `your-project-id.retail_analytics_us.survey_cs_dummy`
WHERE nps_score IS NOT NULL
)
SELECT
nps_category,
COUNT(*) as count,
ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER(), 2) as percentage
FROM nps_classification
GROUP BY nps_category;❓ Problem 2: Calculate NPS Score
Q. Calculate the final NPS score based on the ratios calculated above.
BigQuery (SQL)
View Solution
SELECT
ROUND(
(COUNTIF(nps_score >= 9) - COUNTIF(nps_score <= 6)) * 100.0 / COUNT(*),
1
) as nps_score
FROM `your-project-id.retail_analytics_us.survey_cs_dummy`
WHERE nps_score IS NOT NULL;4. CSAT (Customer Satisfaction) Analysis
CSAT measures satisfaction with a specific interaction (in this case, support). Typically, 4 points (satisfied) and 5 points (very satisfied) are combined for calculation.
❓ Problem 3: Calculate CSAT Score
Q. Calculate the percentage (%) of respondents who gave 4 points or higher out of all responses.
BigQuery (SQL)
View Solution
SELECT
ROUND(COUNTIF(csat_score >= 4) * 100.0 / COUNT(*), 1) as csat_pct
FROM `your-project-id.retail_analytics_us.survey_cs_dummy`
WHERE csat_score IS NOT NULL;5. Advanced: Connecting Tickets and Surveys
Rather than looking at survey data separately, it’s more important to see “Which ticket resolutions led to higher satisfaction?”
❓ Problem 4: Average Satisfaction by Ticket Status
Q. Join with the cs_tickets_dummy table and calculate the average CSAT score by ticket status (status).
BigQuery (SQL)
Hint: Use related_ticket_id and ticket_id as JOIN keys.
View Solution
SELECT
t.status,
ROUND(AVG(s.csat_score), 2) as avg_csat
FROM `your-project-id.retail_analytics_us.survey_cs_dummy` s
JOIN `your-project-id.retail_analytics_us.cs_tickets_dummy` t
ON s.related_ticket_id = t.ticket_id
GROUP BY t.status
ORDER BY avg_csat DESC;💡 Summary and Insights
In this chapter, we quantified the customer’s voice.
- NPS: Measures loyalty (Promoter - Detractor). Shows the long-term health of our service.
- CSAT: Measures experience satisfaction (ratio of 4-5 points). Shows support quality immediately.
- Correlation: Typically, better main product or service experience (High CSAT) tends to correlate with higher recommendation intent (High NPS).
Next Steps: Why are customers dissatisfied? We’ll analyze “Returns” data, one of the biggest sources of complaints, in the next session.