You send the same email blast to your entire customer list. You run the same retargeting ads for everyone. You offer the same discount to a customer who bought yesterday and a customer who last bought eight months ago. RFM analysis segments your customers into named groups based on three numbers (how recently they bought, how often they buy, and how much they spend) so you can stop treating everyone the same and start putting your budget where it matters.
Worked Example: Scoring 30 Simulated Customers
Question: Which customer groups appear in a small sample of order history, and how much order revenue sits in each group?
Inputs: Simulated data, seed 23. The run uses 137 made-up orders from 30 customers and ends on 2025-01-01. Each order has a customer ID, date, and amount.
Method: For each customer, find days since the last order, count orders, and sum order amounts. Rank each measure into five equal-sized bands. A more recent order gets a higher R score; more orders and more revenue get higher F and M scores. Ties are broken by order of appearance, so with 30 customers each band holds exactly 6. Segments use the R and F scores only; M is scored and shown but does not set a segment. The segments come from the standard RFM tool's R and F rules.
Complete Python script:
"""Small RFM example using simulated order data."""
import numpy as np
import pandas as pd
SEED = 23
rng = np.random.default_rng(SEED)
reference_day = pd.Timestamp("2025-01-01")
rows = []
for i in range(1, 31):
customer = f"C{i:02d}"
orders = int(rng.integers(1, 9))
last_days_ago = int(rng.integers(1, 366))
for order_no in range(orders):
# Earlier orders are placed before the customer's most recent order.
gap = int(rng.integers(12, 55))
days_ago = last_days_ago + (orders - order_no - 1) * gap
amount = round(float(rng.uniform(18, 160)), 2)
rows.append((customer, reference_day - pd.Timedelta(days=days_ago), amount))
orders = pd.DataFrame(rows, columns=["customer", "date", "amount"])
summary = orders.groupby("customer").agg(
last_date=("date", "max"), frequency=("date", "size"), monetary=("amount", "sum")
)
summary["recency_days"] = (reference_day - summary["last_date"]).dt.days
# Rank customers into five equal-sized bands; high recency score means more recent.
def quintile(values, high_is_good=True):
ranks = values.rank(method="first", ascending=high_is_good)
return np.ceil(ranks * 5 / len(values)).astype(int)
summary["R"] = quintile(summary["recency_days"], high_is_good=False)
summary["F"] = quintile(summary["frequency"], high_is_good=True)
summary["M"] = quintile(summary["monetary"], high_is_good=True)
# Segments use the R and F scores only; M is scored but does not set a segment.
def segment(r, f):
if r >= 4 and f >= 4: return "Champions"
if r == 3 and f >= 4: return "Loyal"
if r >= 4 and f in (2, 3): return "Potential Loyalist"
if r >= 4 and f == 1: return "New Customers"
if r == 1 and f >= 4: return "Can't Lose Them"
if (r == 1 and f == 3) or (r == 2 and f >= 3): return "At Risk"
if r <= 2 and f <= 2: return "Hibernating"
return "Need Attention"
summary["segment"] = [segment(int(r), int(f)) for r, f in zip(summary.R, summary.F)]
segment_order = [
"Champions", "Loyal", "Potential Loyalist", "New Customers",
"Can't Lose Them", "At Risk", "Hibernating", "Need Attention",
]
print(f"Simulated data, seed {SEED}")
print(f"Input: {len(orders)} orders, {len(summary)} customers; "
f"date window ends {reference_day.date()}")
print("Method: days since last order, order count, and summed order amount; "
"rank each measure into five equal-sized bands; "
"segments use R and F only.")
print("Segment counts and summed customer revenue:")
for name in segment_order:
group = summary[summary.segment == name]
noun = "customer" if len(group) == 1 else "customers"
print(f"{name}: {len(group)} {noun}; {group.monetary.sum():.2f} revenue")
print("Limit: simulated orders do not show real buying habits, profit, "
"or whether a campaign works.")
Real output from running the script with python3:
Simulated data, seed 23
Input: 137 orders, 30 customers; date window ends 2025-01-01
Method: days since last order, order count, and summed order amount; rank each measure into five equal-sized bands; segments use R and F only.
Segment counts and summed customer revenue:
Champions: 4 customers; 2476.75 revenue
Loyal: 3 customers; 1650.41 revenue
Potential Loyalist: 5 customers; 1875.20 revenue
New Customers: 3 customers; 513.68 revenue
Can't Lose Them: 4 customers; 2309.57 revenue
At Risk: 4 customers; 2001.80 revenue
Hibernating: 4 customers; 895.52 revenue
Need Attention: 3 customers; 325.69 revenue
Limit: simulated orders do not show real buying habits, profit, or whether a campaign works.
Result: The run found 4 Champions with 2476.75 in summed revenue, 4 Can't Lose Them with 2309.57, and 4 At Risk with 2001.80. The full count and revenue list is in the output above. The orders are random, so these revenue totals say nothing about real stores. One question to test next: does a welcome note change what New Customers do?
Limit: These are simulated orders. They do not show real buying habits, profit, or whether a campaign works.
What Is RFM Customer Segmentation?
RFM uses time since the last order, order count, and total order value. See the worked example above for a sample score and group report. Recency measures how many days since a customer's last purchase: a customer who bought yesterday may be more likely to buy again than one who last ordered six months ago. Frequency counts total purchases over a given period: repeat buyers may signal loyalty. Monetary sums the total revenue from that customer.
The analysis scores each customer from 1 to 5 on all three dimensions using quintile rankings. A score of 5 means the customer is in the top 20% for that dimension; a score of 1 means they are in the bottom 20%. Segments use the R and F scores only; M is scored and shown but does not set a segment. The result is a customer base classification that maps to marketing actions you can take this week.
Why This Matters for Your Store
Many e-commerce businesses spend most of their marketing budget on acquisition (Meta ads, Google Shopping, influencer partnerships) while treating their existing customer base as a single undifferentiated list.
RFM segmentation shows where your customers sit today. Customers in the At Risk segment were previously frequent buyers who have gone quiet. They already know your product, so a targeted win-back email to this group is a different job from acquiring a new customer. Test it against your own results.
When to Use RFM Segmentation
- You are sending the same emails to everyone. Your email list has 2,000 customers but one segment. Champions should get referral incentives and early access. At Risk customers should get win-back offers with free shipping. Hibernating customers may be worth leaving out of regular sends.
- Your repeat purchase rate is flat or declining. RFM identifies the Potential Loyalists: customers who bought two or three times recently and are one positive experience away from becoming Loyal. Targeted second-purchase incentives for this group move the needle faster than blasting the whole list.
- You need to justify retention spend to a partner or investor. A statement like "Our At Risk segment contains a set number of customers representing a set amount of trailing annual revenue" is a business case. "We should do more retention" is not.
- You are running paid retargeting. Custom audiences built from RFM segments can be compared with generic past-purchaser audiences; test which one performs better for you.
- Before a major sale or product launch. Know which segments to invite first. Champions get early access. Potential Loyalists get a reason to come back. Hibernating customers may not be worth the discount.
What Data Do You Need?
You need a CSV with transaction-level records: one row per purchase, not one row per customer. The required columns are a customer identifier (account ID, email, or customer number), a transaction date, and a revenue or amount column. That is it. Three columns.
Where to get the export
- Shopify: Settings > Data > Export > Orders. Select "All orders" and export as CSV. The file will contain Customer Email, Created at (date), and Total (amount).
- WooCommerce: WooCommerce > Reports > Export Orders CSV. Map customer email, order date, and order total.
- Stripe: Dashboard > Payments > Export. You get customer ID, date, and amount.
- Any other system: Any CSV with a customer identifier, a date, and an amount per transaction will work.
How much data
With few customers, each score band holds only a handful of people, so segment assignments are noisy. Shorter windows may miss seasonal buyers; longer windows may dilute recency signals. Choose a window that fits how often your customers buy.
What does not work
If your product is a one-time purchase with no repeat buying opportunity, like furniture or real estate, RFM's frequency dimension adds no signal. Nearly every customer will score F=1. In that case, a simpler recency-monetary ranking is more appropriate. But for apparel, beauty, supplements, pet supplies, food and beverage, home goods, subscription boxes, and most DTC categories, repeat purchasing is common, so there is more for RFM to work with.
Customer Segments
The analysis assigns every customer to a named segment. The segments come from the standard RFM tool's R and F rules. Segments use the R and F scores only; M is scored and shown but does not set a segment. Each segment suggests an action you could take.
Champions (R4-5, F4-5): Your best customers by recency and frequency. They bought recently and buy often. These are your referral candidates, beta testers, and brand advocates. Consider not discounting to this group, and ask them for reviews and referrals instead.
Loyal (R3, F4-5): Consistent repeat buyers. Reward their loyalty with exclusive access or early product launches.
Potential Loyalist (R4-5, F2-3): Recent customers who have bought a few times. One or two more positive experiences may move them into Loyal territory. Targeted product recommendations and second-purchase incentives are worth testing here.
New Customers (R4-5, F1): One purchase, recently. Welcome sequences, satisfaction surveys, and free shipping on a second order are options to test.
Need Attention (everyone else: R3 with F1-3): Middling recency and frequency. Not in danger yet, but not growing either. A personalized email or a product update announcement can be tried here.
At Risk (R1 with F3, or R2 with F3-5): These customers used to buy fairly often but have gone quiet. They were once valuable and could be again. Win-back campaigns with a clear offer are worth testing, because you already know they bought from you.
Can't Lose Them (R1, F4-5): Frequent buyers who have gone dark. Escalate these first: a phone call, a personal note, or a concession on a past complaint could bring them back.
Hibernating (R1-2, F1-2): Low on recency and frequency. They bought once or twice a while ago and have not returned. Batch email campaigns or lookalike audience exclusions are low-effort options; one-on-one effort here may not pay back.
How to Read the Report
RFM Score Heatmap: The heatmap plots Recency scores on one axis and Frequency on the other, with each cell colored by average Monetary value. Hot cells in the top-right corner (high R, high F, high M) are your Champions. Cold cells in the bottom-left are Hibernating customers. A healthy business has significant mass in the upper-right quadrant. If most of the weight sits in the lower-left, your acquisition funnel is leaking. You are acquiring customers who never come back.
Segment Distribution: The horizontal bar chart shows how many customers fall into each segment. A large share in Hibernating or At Risk points to a retention problem; a large share in Champions and Loyal suggests your retention engine is working. This chart gives you the structural health of your customer portfolio at a glance.
Revenue Treemap: Sizes each rectangle by the segment's total revenue contribution. Champions might be a small share of customers but a large share of revenue. The treemap makes that concentration visible. This is the chart to show your partner or investor when arguing for retention investment. If At Risk and Can't Lose Them together hold a large share of revenue, the case for a win-back campaign is easier to make.
Customer Value Bubble Chart: Positions individual customers by their RFM scores, with bubble size proportional to revenue. It reveals outliers that aggregate views hide. You might spot a single customer with an enormous bubble sitting in the At Risk zone. That is a phone call you need to make today.
Top Customers Table: Ranks top customers by combined RFM score, showing individual R, F, and M scores, segment assignment, and total revenue. This is the tactical output: names or IDs your team can act on immediately. Sort by segment to find your highest-value At Risk accounts or filter to Champions for a referral outreach list.
Segment Summary Table: Aggregates each segment with customer counts, percentage of total, average monetary value, average recency, and average frequency. Run the analysis monthly and track whether your At Risk segment is growing or shrinking. A rising At Risk share over several months is an early warning that something in your product, pricing, or service has changed.
Executive Summary: The AI-generated TL;DR distills the entire analysis into key findings and recommended actions. It highlights revenue concentration risks, flags the most impactful segments, and suggests specific next steps. This is the slide you paste into your Monday meeting deck.
What to Do With the Results
This week
- Export your At Risk and Can't Lose Them lists. These are customers who used to buy often. Send them a personal win-back email with a clear offer. A phone call is another option for Can't Lose Them accounts.
- Build a Champions custom audience. Upload your Champions list to Meta or Google Ads and create a lookalike audience. These are your best customers: people who look like them are your best acquisition targets.
- Set up a New Customer welcome flow. If you are not sending a dedicated welcome sequence to first-time buyers, you are losing them. The New Customers segment tells you exactly who needs this flow right now.
This month
- Create segment-specific email flows in Klaviyo or Mailchimp. Champions get referral requests and early access. Potential Loyalists get product recommendations and second-purchase incentives. At Risk gets win-back offers. Hibernating gets a last-chance reactivation or is left out of regular sends.
- Review ad spend allocation. Review your ad and retention plans, then choose a budget shift based on your own results.
Ongoing
- Run the analysis monthly or quarterly. Customers move between segments. Track migration patterns: are your Potential Loyalists converting to Loyal, or are they sliding toward At Risk? Segment migration over time is the most actionable retention metric you can track.
- Cross-reference with product data. Which products do Champions buy most? Which products appear in first orders that lead to repeat purchases? Use the segmentation as a lens on your product catalog.
When to Use Something Else
- Want to predict who will churn next month: RFM tells you who is at risk today based on past behavior. If you need individual churn probabilities projected forward, use a churn prediction model that incorporates usage patterns, support tickets, and engagement signals beyond purchase history.
- Have more than three behavioral dimensions: If your customer data includes page views, support tickets, NPS scores, and app usage alongside purchase data, consider k-means clustering or DBSCAN clustering. These methods segment on any number of features, while RFM is intentionally constrained to three.
- Want to compare two groups statistically: Use a t-test (e.g., do Champions and At Risk customers differ significantly in AOV?) or ANOVA (compare average order value across all segments).
- Sell one-time purchases: If your product is bought once (furniture, mattresses, real estate), frequency adds no signal. A simpler recency-monetary ranking or a CLV model is more appropriate.
- Want the conceptual background: For a deeper walkthrough of RFM methodology and manual implementation, see our RFM practical guide.
Your turn
Bring your own data and the question you actually need answered.
MCP AnalyticsData science by email Send us your data and your question, and we will reply. ds@mcpanalytics.ai