Extrait public
Verrouillé
Classic, unbounded or bracket retention? Chosen for your business, then: cohort CTE, activity CTE, period index, censored cells set to NULL, pandas pivot + heatmap with cohort sizes, and how to read rows, columns and diagonals…
À propos de ce prompt
From your orders or events table, builds a proper cohort retention analysis: the right retention definition for your business, a SQL query that masks incomplete periods, Python code for the triangle heatmap and curves, and a guide to reading it (flattening point, vertical vs diagonal patterns, small-cohort noise). Ends with sanity checks so the triangle can be trusted.
Exemple de résultat
STEP 1 — Definition
Repeat-purchase e-commerce → classic monthly retention on paid orders. The current month is censored (NULL). Orders with status 'refunded' and users flagged is_test are excluded.
STEP 2 — SQL (PostgreSQL)
```sql
WITH first_orders AS (
SELECT user_id,
DATE_TRUNC('month', MIN(created_at AT TIME ZONE 'Europe/Paris')) AS cohort
FROM orders WHERE status = 'paid' GROUP BY user_id
), activity AS (
SELECT DISTINCT user_id, DATE_TRUNC('month', created_at AT TIME ZONE 'Europe/Paris') AS active_month
FROM orders WHERE status = 'paid'
)
SELECT f.cohort,
(EXTRACT(YEAR FROM age(a.active_month, f.cohort)) * 12 + EXTRACT(MONTH FROM age(a.active_month, f.cohort)))::int AS period_index,
COUNT(DISTINCT a.user_id) AS retained_users
…
```
STEP 4 — Reading
Read down column 3: if newer cohorts sit consistently higher, the onboarding change is a candidate explanation, not a proof…
Fiche technique
- Modèle
- Claude
- Langue du prompt
- Anglais
- Pour qui
- Data analysts, growth and product teams in SaaS, apps and e-commerce
- Longueur
- ~612 tokens (estimation)
- Format livré
- Texte du prompt, affiché en ligne après achat
- Rayon
- Data & Analyse
Avis
Aucun avis pour l'instant. Seuls les acheteurs de ce prompt peuvent en laisser un.