Public excerpt
Locked
Refunds and test orders excluded, a fixed analysis date, quintiles with a fallback when frequency is tied, NTILE SQL + pandas qcut code, 8 to 11 named segments (Champions, At risk, Can't lose them…), an action plan per segment and a holdout to prove impact…
About this prompt
Builds an RFM (recency, frequency, monetary) segmentation from your transaction table: clean-up rules, scoring that copes with the classic problem of most customers having only one order, SQL and pandas code, a named segment map, and a marketing plan per segment with what not to do. Ends with how to measure campaign impact with a holdout group.
Example output
STEP 2 — Frequency problem
If more than 40% of customers have exactly 1 order, NTILE puts identical customers in different F scores. Use the business bins instead: F1 = 1 order, F2 = 2, F3 = 3–4, F4 = 5–9, F5 = 10+.
STEP 3 — SQL (PostgreSQL)
```sql
WITH base AS (
SELECT customer_id,
DATE '2025-10-31' - MAX(order_date)::date AS recency_days,
COUNT(DISTINCT order_id) AS frequency,
SUM(net_amount) AS monetary
FROM orders
WHERE status = 'paid' AND order_date > DATE '2025-10-31' - INTERVAL '24 months'
GROUP BY customer_id
)
SELECT *, 6 - NTILE(5) OVER (ORDER BY recency_days) AS r_score, …
```
STEP 5 — Action plan
| Segment | Rule | Objective | Channel | Offer | Do not |
| Can't lose them | R ≤ 2, F ≥ 4 | Win back high-value lapsed buyers | Personal email from founder | Strong | Send the generic newsletter |
| Champions | R = 5, F ≥ 4 | Referrals, early access | Email | None | Discount them |
…
Details
- Model
- ChatGPT
- Prompt language
- English
- Who it's for
- E-commerce managers, CRM and retention marketers, and analysts in retail or DTC brands
- Length
- ~574 tokens (estimate)
- Delivered as
- Prompt text, shown online after purchase
- Category
- Data & Analytics
Reviews
No reviews yet. Only buyers of this prompt can leave one.