RFM Analysis — A Customer Segmentation Strategy — When, What, How, Why?

Meghana Rangarajan
3 min readApr 17, 2023

--

RFM Analysis — Segmenting customers based on their Recency, Frequency and Monetary Value.

WHEN is RFM Analysis Used?

RFM analysis is used to divide an existing customer base of ecommerce businesses based on purchase patterns and customer behavior.

These insights are used to tailor their marketing strategy with messages and offers relevant to all these segments. This in-turn will lead to better customer acquisition, retention and conversion.

WHAT is RFM?

The RFM analysis uses the purchase data of the business’ customers and assigns an RFM score based on 3 significant factors —

  • Recency — How recently a customer has made a purchase
  • Frequency — How often a customer makes a purchase
  • Monetary — How much money a customer spends on the purchase

This RFM score can be used to make a reasonable prediction as to how likely it is for customers to interact with the business again and how much they will spend.

HOW to perform RFM Analysis?

INPUT DATA TO THE RFM MODEL

The input for the RFM analysis can be an Excel/Table/Database with —

  1. Date of the purchase
  2. Unique User Identifier
  3. Purchase Amount
Sample Input Data for RFM Analysis

CODE TO PERFORM RFM ANALYSIS

library(rfm)
library(lubridate)
library(data.table)
library(dplyr)

Sys.setenv(TZ='UTC')
analysis_date <- Sys.Date()

###################################################
### Enter the Location of the Input File
###################################################
input_file_path = "D:/RFM_Analysis/RFM_input_file.csv"
raw_data = read.csv(file = input_file_path)

###################################################
### rfm_table_order() - Assigns an RFM Score
###################################################
rfm_result<-rfm_table_order(raw_data,customer_id = uid,order_date = dt,revenue = rev,analysis_date = analysis_date)
rfm_final_output = as.data.frame(rfm_result$rfm)

###################################################
### Enter the Location to write the Output File
###################################################
output_file_path = "D:/RFM_Analysis/RFM_output_file.csv"
write.csv(rfm_final_output,output_file_path)

rfm_table_order() — This function gives the userID a recency, frequency, and monetary score. It also shows the last time a customer made a purchase, their total number of transactions and total revenue.

OUTPUT OF THE RFM ANALYSIS

Sample Output for RFM Analysis

WHY is RFM Analysis performed?

The main goal of RFM analysis is to segment the customers. This can be done based on the business requirements.

Here’s an example of how the segmentation can be done for an e-commerce business —

Segmentation Methodology
Strategies for each segment

Champions & Loyal Customers

These are the customers who have very high R, F and M Scores. which means they are spending a lot lately, very frequently.

  • Analyze these customers’ purchased products and find their preferences for Upsell Strategies.
  • Reward their continued selection of the brand with Loyalty Reward programs & Referral programs.

Potential Loyalists

They are spending moderate amounts very frequently. Our aim to make them spend more in order to make them champions.

  • Make Limited Time Offers.
  • Show specific discounts on certain products based on their purchase patterns and increase their will to be amongst the most loyal customers of the brand.

Low Spenders & At-Risk Customers

Their R, F, M scores are at the lower side of the range. They have not spent a lot or haven’t interacted with the business frequently/recently.

  • Revive their interest with reach out campaigns. Making them aware of certain aspects of the website.
  • Provide incentives for purchasing products on the website and post-purchase coupons to make them return to the website.

One Time Customers

Irrespective of their R/M scores, their F score is 1. i.e. They have made a purchase only once from the business.

  • Since we want them to purchase more often, they’re a perfect target for reward-based campaigns.
  • Try to Cross Sell — Making them aware of frequently bundled cross category products might yield good results.

--

--

Meghana Rangarajan

Where there is data smoke, There is business fire. Senior Business Analyst @ MiQ Digital.