Back to cookbook

AI Prompt to Build an RFM Customer Segmentation Model From Purchase Data

0 views Updated

Make this prompt yours

Share

This prompt guides ChatGPT, Claude, or Gemini through building an RFM (Recency, Frequency, Monetary) customer segmentation model directly from a raw purchase or transaction export, without requiring the user to write SQL or Python first. It's built for ecommerce analysts, growth marketers, and small business owners who have a list of orders with customer IDs, dates, and amounts, and need to turn that into actionable customer segments like "Champions," "At Risk," or "Lost" customers.

The prompt walks the model through calculating recency (days since last purchase), frequency (number of orders in the period), and monetary value (total or average spend), then scoring each metric on a 1-5 scale and combining the three scores into named segments. It also asks the model to flag any data issues — missing dates, duplicate orders, refunds mixed into totals — before it starts scoring, so the segmentation isn't built on dirty inputs.

For teams whose transaction history lives in a large export with far more columns than RFM needs, pulling only the customer ID, order date, and order total columns first makes the segmentation faster and less error-prone; Context Extractor is built for isolating exactly those relevant rows and columns out of a bigger CSV before this prompt ever sees the data.

Prompt template

Make this prompt yours

prompt-template
353 tokens
ROLE: You are a customer analytics specialist helping me segment customers using the RFM (Recency, Frequency, Monetary) framework. CONTEXT: - Data: [DESCRIBE YOUR DATA - e.g. "a CSV with columns: customer_id, order_date, order_total"] - Analysis period: [TIME RANGE, e.g. "last 12 months"] - Business type: [E.G. ECOMMERCE, SUBSCRIPTION, RETAIL] - Number of segments wanted: [NUMBER, e.g. "5-7 named segments"] TASK: 1. First, review the data I provide and flag any quality issues (missing values, duplicate orders, refunds, or inconsistent date formats) before scoring anything. 2. Calculate Recency, Frequency, and Monetary values per customer based on the period above. 3. Score each metric from 1 (worst) to 5 (best) relative to the full customer base. 4. Combine the three scores into a single RFM code and assign each customer to a named segment (e.g. Champions, Loyal Customers, At Risk, Lost). 5. Summarize how many customers fall into each segment and one recommended action per segment. CONSTRAINTS: - State the scoring thresholds you used so the method can be repeated on future data - Do not invent data points that are not in the file I provide - If a required column is missing, ask me for it instead of assuming OUTPUT FORMAT: - A table: customer_id | recency_score | frequency_score | monetary_score | RFM_segment - A short summary section listing segment names, customer counts, and one action per segment DATA: [PASTE OR DESCRIBE YOUR CUSTOMER PURCHASE DATA HERE]

Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.

Example input

example-input
198 tokens
ROLE: You are a customer analytics specialist helping me segment customers using the RFM framework. CONTEXT: - Data: CSV with columns customer_id, order_date, order_total for an online skincare store - Analysis period: last 12 months (today is October 2026) - Business type: ecommerce, repeat-purchase consumables - Number of segments wanted: 6 named segments DATA (sample rows): customer_id,order_date,order_total C1001,2026-09-28,54.00 C1001,2026-06-14,32.00 C1002,2025-11-02,18.50 C1003,2026-10-15,120.00 C1003,2026-08-01,95.00 C1003,2026-05-20,88.00 C1004,2024-03-10,42.00

When to use it

  • You have a spreadsheet or CSV export of customer orders and want to group customers by buying behavior
  • You're planning a win-back or loyalty campaign and need to know who counts as "at risk" versus "loyal"
  • You want a repeatable scoring method instead of eyeballing which customers matter most
  • You need to explain customer segments to a non-technical stakeholder in plain business terms

Best practices

  • Give the model the actual column names from your file so it maps recency, frequency, and monetary fields correctly instead of guessing
  • Specify the analysis period (e.g. "last 12 months") so recency and frequency scores aren't skewed by very old orders
  • Ask for the segment definitions and score cutoffs up front so the output is reproducible next quarter, not a one-off
  • Request the output as a table with customer ID, each RFM score, and the final segment name so it can be pasted straight into a spreadsheet

Common mistakes

  • Feeding in a transaction log that still includes refunds or cancelled orders, which inflates monetary and frequency scores
  • Not specifying how many segments you want, so the model picks an arbitrary number that doesn't match your campaign plans
  • Treating RFM scores as exact math instead of a relative ranking within your own customer base
  • Skipping the data-quality check step and segmenting on a file with duplicate customer IDs or missing dates

FAQs

What is RFM analysis in customer segmentation?

RFM stands for Recency, Frequency, and Monetary value — three metrics used to score and group customers based on how recently they bought, how often they buy, and how much they spend, so marketing effort can be targeted at the segments that matter most.

Can ChatGPT actually calculate RFM scores from a spreadsheet?

Yes, if you paste in or describe the actual order data with customer IDs, dates, and amounts, ChatGPT, Claude, or Gemini can calculate recency, frequency, and monetary values and score them, though for very large datasets a spreadsheet or BI tool is more reliable for the raw math.

How many RFM segments should I use?

Most teams use 5 to 8 named segments (such as Champions, Loyal, At Risk, and Lost); fewer segments are easier to act on, while more segments give finer targeting at the cost of simplicity.

Which Cuelara tool can help me clean up my data before running this RFM prompt?

Context Extractor — pulls only the relevant customer, date, and order columns out of a large or messy transaction export so the RFM prompt scores clean data instead of a noisy full file.

Found this prompt useful? Share it.

Share

More in Data Analysis & Data Science

Data Analysis & Data Science

AI Prompt to Build a Cohort-Based Customer LTV Analysis From Transaction Data

This AI prompt for customer LTV analysis walks a model through building a cohort based customer lifetime value study from raw transaction da…

ROLE
You are a data analyst specializing in customer lifetime value (LTV) and cohort analysis.

CONTEXT
I am analyzing transaction data for [BUSINESS TYPE / PRODUCT] to understand customer lifetime value by acquisition cohort.
Data provided: [DESCRIBE COLUMNS, E.G. CUSTOMER_ID, TRANSACTION_DATE, REVENUE, CHANNEL]
Time range: [START DATE] to [END DATE]
Cohort definition: [E.G. SIGNUP MONTH, ACQUISITION CHANNEL, CAMPAIGN NAME]

TASK
1. Group customers into cohorts based on [COHORT DEFINITION].
2. For each cohort, calculate cumulative revenue per customer at [TIME INTERVALS, E.G. MONTH 1, 3, 6, 12].
3. Identify which cohorts show the fastest payback relative to an acquisition cost of [CAC VALUE, IF KNOWN].
4. Flag any data quality issues (duplicate IDs, missing dates, negative revenue from refunds) that could distort the results.
5. Summarize which cohorts are most and least valuable, and why.

CONSTRAINTS
- Do not blend one-time revenue (shipping, tax, fees) into the LTV calculation unless explicitly told to.
- State any assumptions made about missing or ambiguous data.
- Keep the cohort definition consistent across the entire analysis.

OUTPUT FORMAT
- A short summary of findings (3-5 sentences)
- A table of cohorts with cumulative LTV at each time interval
- A ranked list of cohorts from most to least valuable
- A list of data quality flags, if any

Make this prompt yours

Data Analysis & Data Science

ChatGPT Prompt for Exploratory Data Analysis on a New Dataset

This ChatGPT prompt for exploratory data analysis (EDA) is built for analysts, students, and data scientists opening a dataset for the first…

Role: You are a data analyst performing an initial exploratory analysis on a new dataset.

Context:
- Dataset description: [WHAT THE DATA REPRESENTS AND WHERE IT CAME FROM]
- Columns and data types: [LIST COLUMN NAMES AND TYPES]
- Sample rows: [PASTE 5-10 SAMPLE ROWS]
- Business question or goal: [WHAT YOU'RE ULTIMATELY TRYING TO UNDERSTAND OR DECIDE]

Constraints:
- Base every observation only on the data provided; do not invent values or trends not shown
- Clearly separate factual observations from suggested next steps
- Flag any columns with likely data-quality issues (missing values, inconsistent formatting, outliers)
- If something cannot be determined from the sample provided, say so explicitly instead of guessing

Output format:
1. Dataset overview (shape, column types, general structure)
2. Data-quality issues found (missing values, duplicates, inconsistent formats)
3. Key distributions and notable patterns
4. Three to five follow-up questions worth investigating further

Make this prompt yours

Data Analysis & Data Science

ChatGPT Prompt to Forecast Sales Trends From Historical Time-Series Data

This sales trend forecasting prompt turns a column of historical sales numbers into a structured, defensible forecast instead of a guess dre…

ROLE
You are a data analyst specializing in sales forecasting and time-series pattern recognition.

CONTEXT
I'm forecasting [METRIC, e.g. monthly revenue / weekly units sold] for [BUSINESS OR PRODUCT LINE] over [TIME PERIOD, e.g. the next 3 months]. Below is the historical data for [NUMBER] periods:

[PASTE DATE/VALUE TABLE HERE]

Known anomalies or one-time events in this history: [LIST ANY PROMOTIONS, STOCKOUTS, PRICE CHANGES, OR SKIP IF NONE]

CONSTRAINTS
- Base the forecast only on the patterns present in the data provided; do not assume external market trends unless I state them.
- Explicitly separate trend, seasonality, and noise in your explanation.
- If the history is too short or too irregular to forecast reliably, say so and explain what additional data would help.
- Do not present a single number as certain; always frame it as an estimate with a stated confidence range.

OUTPUT FORMAT
1. A one-paragraph summary of the pattern you identified (trend direction, seasonality if any, anomalies excluded).
2. A period-by-period forecast table for [NUMBER OF FUTURE PERIODS] periods, with columns: Period | Low Estimate | Expected | High Estimate.
3. A short list of the key assumptions behind the forecast.
4. A note on what would most improve forecast accuracy (more history, more granularity, external data, etc.).

Make this prompt yours