Customer Segmentation — RFM Analysis

Tan Khuu
Tan Khuu
Jun 16, 2017 · 5 min read

Some readers asked me about how to implement this RFM Analysis? So I added a Simple RFM Analysis implementation on GitHub in case you have the same question. It used NodeJS and Elasticsearch.

Over 2 years ago, we had the chances to join the “Innovation Time Off” when I worked in Navigos Group. “Innovation Time Off” is a motivation technique which applied by Google, when all Google engineers are encouraged to spend 20% of their work time (1 day per working week) on projects that interest them. In Navigos, Chris Shayan gave us the chances to come to a beautiful place (big villa in Ho Tram) and spent whole day to work on projects that you are interested in and will be useful for the Business, another day we can enjoy our life and relax to refresh our mind in that place. That was the time when “RFM Analysis” came to my mind.

As a member of Data team, we had the mission to research on “How can we use our data to help for up-selling our products?”. I realized that the more we understand about our customers the more efficient actions we can consider to apply. And there are a ton of questions that we need to answer to finish our mission:

  • Why can’t we up-sell for these customers?
  • People who spend the most are your best customers, is it true? (What if they purchased only once? Or a very long time ago? What if they are no longer using your product?)
  • You want to up-sell customers, who do you should pay attention on? Is this the right time to call them? Can we promote them?

Well, Customer Segmentation can help us.

Customer Segmentation — The secret to success by achieving more with less

Customer segmentation is the practice of dividing a customer base into groups of individuals that are similar in specific ways relevant to marketing, such as age, gender, interests and spending habits.” from SalesForce.

This video will help us to understand more about what the Customer Segmentation is and how can it help to boost the sales of your business:

RFM Analysis — How we implement Customer Segmentation.

RFM (Recency, Frequency, Monetary) is a very Simple Technique that we can apply it very easy and get the super useful analysis for our Customer Segmentation

RFM considers recency, frequency and monetary values for each customer. Combines them, and then groups them into different customer segments for easy recall and campaign targeting. It’s super useful in understanding responsiveness of your customers and for segmentation driven database marketing.

RFM analysis readily answers these questions for your business…

  • Who are my best customers?
  • Which customers are at the verge of churning?
  • Who has the potential to be converted in more profitable customers?
  • Who are lost customers that you don’t need to pay much attention to?
  • Which customers you must retain?
  • Who are your loyal customers?
  • Which group of customers is most likely to respond to your current campaign?

(Reference from Putler).

How can we apply RFM in Business?

Choose the period for your data collection:

It coul be 3 months, 6 months, 1 year, 3 years.

Calculate RFM Values:

We need a few details of each Customers:

  • Customer ID / Name / Company etc — to identify them
  • Recency (R) as days since last purchase: How many days ago was their last purchase? Deduct most recent purchase date from today to calculate the recency value. 1 day ago? 14 days ago? 500 days ago?
  • Frequency (F) as total number of transactions: How many times has the customer purchased from our store? For example, if someone placed 10 orders over a period of time, their frequency is 10.
  • Monetary (M) as total money spent: How many $$ (or whatever is your currency of calculation) has this customer spent? Simply total up the money from all transactions to get the M value.

Here is the example:

RFM Values for Customers

Applying RFM Score Formula

This is the very important step for RFM Analysis. RFM values and RFM scores are different. Value is the actual value of R/F/M for that customer, while Score is a number from 1–5 based on the value.

How to calculate RFM score on scale of 1–5?

We use Quintiles — Make five equal parts based on available values — to calculate RFM score.

RFM Quintiles for data in 1 year

Base on these quintiles, and the RFM Values that we had before. We can calculate and scoring the RFM for our customers. Example: Customer 386 who has :

  • Recency value: 5. It is in the 5th quantile of Recency Score Range, which is range from 32 days to 0 days → his RScore will be 5.
  • Frequency value: 56, it is in the 5th quantile of Frequency Score Range, which is range from 41 to 84 SOs → his FScore will be 5.
  • Monetary value: 100,000,000. It is in the 5th quantile of Monetary Score Range, which is range from 8,991,000 to 100,000,000 → his MScore will be 5.

Repeating the calculating for every customer, we could have the result like this:

RFM Scores of Customers

Well, we are good until now, after we have RFM Scores for our Customers, all we need to do next is Segmenting them. Thanks to anh Ngo Anh Tuan and Chris Shayan for suggesting this gorgeous tool Gandalf — an Open-Source Decision Engine for Big-Data. This tools will help us on user Segmentation base on the RFM Scores that we had:

Decision making for segmenting Customers

Show time

Now It will be the good time to visualize our result:

Awesome, What can we do next?

We have:

  • 20 Champions: Reward them. Can be early adopters for new products. Will promote our brand.
  • 149 Loyal Customers: Up-sell higher value products. Ask for reviews. Engage them.
  • 1,262 Potential Loyalist: Offer membership / loyalty program, recommend other products.
  • 10 At Risk: Send personalized emails to reconnect, offer renewals, provide helpful resources.
  • 43 Hibernating: Offer other relevant products and special discounts. Recreate brand value.


Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store