RFM analysis

Published December 20, 2021
Modules
Difficulty
Selected Clients
carrefour logoeobuwie logo

RFM segmentation is a method used to identify clusters of customers for special treatment. It is commonly used in database marketing and direct marketing, and has received particular attention in many different industries. In order to differentiate customers from data sets, the RFM method uses three different attributes:

  • Recency of the last purchase (R) - refers to the interval between the time of the latest customer purchase and the current date. The shorter the interval between current date and last purchase, the higher R score is.
  • Frequency of the purchases (F) - refers to the number of transactions in a particular period. The higher number of transactions, the higher the F score is.
  • Monetary value of the purchases (M) - refers to monetary value of products purchased by the customer. The more the customer spends, the higher the M score is.

This lets you isolate groups, identify new or most active customers, and target personalized messages based on transaction data.

RFM analysis

Prerequisites


  • Come up with the categories you want to organize your customers, for example: Top customers, Recent customers, Churn risk, Heavy buyers, Lost heavy buyers, Lost customers.

Process


  1. Create a number of basic analyses, so you can later use them in more complex calculations.
  2. Create a set of metrics for Recency, Frequency, and Monetary scores to return the value of 0.20, 0.40, 0.60, 0.80 quantiles. This way you receive four thresholds for all scores.
  3. Create a dashboard to conveniently display the results of the metrics.
  4. Prepare segments for Recency, Frequency, and Monetary scores based on the values returned by the metrics you created before. The sub-segmentation are named in the following way:
    • For Recency score: 500, 400, 300, 200, 100
    • For Frequency score: 50, 40, 30, 20, 10
    • For Monetary score: 5, 4, 3, 2, 1
  5. Create an expression that adds all three segmentations, the example result is 555, which is the highest score a customer can get.
  6. Create a RFM segmentation that contains the sub-segmentations which correspond to the customer categories (for example, Top customers, Heavy buyers, Lost customers, and so on). Decide the range of scores for each category.
Note: You can find furhter explanation in the corresponding sections in the article.

Create a set of basic analyses


In this part of the process, you must create a number of analyses which will be reused in the further part of the process.

Number of transactions

Create the aggregate that calculates the number of transactions for a single customer in the last 90 days. It will be reused in the further analyses.

Tip: You can read more about aggregates here.
  1. Go to Analytics icon Analytics > Aggregates > New aggregate.
  2. Enter a meaningful name of the aggregate.
  3. Set the Aggregate option to Count.
  4. Click the Choose event dropdown list.
  5. From the dropdown list, select the event that signifies a purchase.
    Tip: Events may have different labels between workspaces, but you can always find them by their action name (in this step, it’s transaction.charge).
  6. Using the date picker in the lower-right corner, set the time range to Relative time range > Custom > last 90 days.
  7. Save the aggregate.
The aggregate that returns the number of transactions in last 90 days for a customer
The aggregate that returns the number of transactions in last 90 days for a customer

Time of the first purchase

Create the aggregate which returns the time when a customer made the first purchase in the last 90 days. It will be reused in the further analyses.

  1. Go to Analytics icon Analytics > Aggregates > New aggregate.
  2. Enter a meaningful name of the aggregate.
  3. Set the Aggregate option to First.
  4. Click the Choose event dropdown list.
  5. From the dropdown list, select the event that signifies a purchase.
    Tip: Events may have different labels between workspaces, but you can always find them by their action name (in this step, it’s transaction.charge).
  6. Click + where button.
  7. On the dropdown list, click Three dot icon > Specials.
  8. Choose TIMESTAMP.
  9. Using the date picker in the lower-right corner, set the time range to Relative time range > Custom > last 90 days.
  10. Save the aggregate.
The aggregate that returns the time of first transaction of a customer in last 90 days
The aggregate that returns the time of first transaction of a customer in last 90 days

Time of the last purchase

Create the aggregate which returns the time when a customer made the latest purchase in the last 90 days. It will be reused in the further analyses.

  1. Go to Analytics icon Analytics > Aggregates > New aggregate.
  2. Enter a meaningful name of the aggregate.
  3. Set the Aggregate option to Last.
  4. Click the Choose event dropdown list.
  5. From the dropdown list, select the event that signifies a purchase.
    Tip: Events may have different labels between workspaces , but you can always find them by their action name (in this step, it’s transaction.charge).
  6. Click + where button.
  7. On the dropdown list, click Three dot icon > Specials.
  8. Choose TIMESTAMP.
  9. Using the date picker in the lower-right corner, set the time range to Relative time range > Custom > last 90 days.
  10. Save the aggregate.
The aggregate that returns the time of last transaction in last 90 days for a customer
The aggregate that returns the time of last transaction in last 90 days for a customer

Value of purchase

Create the aggregate that returns the total amount of money a single customer spent in the last 90 days.

  1. Go to Analytics icon Analytics > Aggregates > New aggregate.
  2. Enter a meaningful name of the aggregate.
  3. Set the Aggregate option to Sum.
  4. Click the Choose event dropdown list.
  5. From the dropdown list, select the event that signifies a purchase.
    Tip: Events may have different labels between workspaces, but you can always find them by their action name (in this step, it’s transaction.charge).
  6. Click + where button.
  7. On the dropdown list, select the parameter that signifies the total amount of a transaction, for example, $totalAmount
  8. Using the date picker in the lower-right corner, set the time range to Relative time range > Custom > last 90 days.
  9. Save the aggregate.
The aggregate that returns the total amount of money a customer spent in last 90 days
The aggregate that returns the total amount of money a customer spent in last 90 days

Number of days since last transaction

Create an attribute expression that calculates how many days passed since the last transaction. This expression reuses the aggregate that returns the timestamp of the last transaction in the last 90 days.

  1. Go to Analytics icon Analytics > Expressions > New expression.

  2. Enter a meaningful name of the expression.

  3. Leave the expression type at default (Attribute).

  4. Build the following expression formula:

    The expression formula that returns the number of days that passed since the last transaction
    The expression formula that returns the number of days that passed since the last transaction
    Click here to watch the video tutorial

    In the formula of the expression, you must deduct the date of the last transaction from the current date and divide the result by 86400000 to receive the number of days which passed since the last purchase.

  5. Save the expression.

Time from the first transaction

Create an attribute expression that calculates how much time passed since the last transaction. This expression reuses the aggregate that returns the timestamp of the first transaction in the last 90 days and it will be reused in the expression that returns the number of weeks that passed from the first transaction.

  1. Go to Analytics icon Analytics > Expressions > New expression.

  2. Enter a meaningful name of the expression.

  3. Leave the expression type at default (Attribute).

  4. Build the following expression formula:

    The expression formula that returns the time that passed since the first transaction
    The expression formula that returns the time that passed since the first transaction
    Click here to watch the video tutorial

    In the formula of the expression, you must deduct the date of the first transaction from the current date. The result of the expression is given in milliseconds.

  5. Save the expression.

Weeks from the first transaction

Create an expression that calculates the number of weeks since the first transaction of a customer in the last 90 days. This expression reuses the expression that calculates the time from the first transaction.

  1. Go to Analytics icon Analytics > Expressions > New expression.
  2. Enter a meaningful name of the expression.
  3. Leave the expression type at default (Attribute).
  4. Build the following expression formula:
    1. Click the Select node.
    2. From the dropdown list, select Customer.
    3. Click the unnamed node that has been added to the canvas.
    4. Scroll down the page and click Choose attribute.
    5. Search and select the expression that calculates the time from the first transaction.
    6. Next to the expression on the canvas, click the plus button icon.
    7. Select Constant.
    8. Click 0 that has been added to the canvas.
    9. Change the number to 604800000.
    10. Click the mathematical operator between the nodes and change it to a division sign.
  5. Save the expression.
The expression formula that returns the number of weeks that passed since the first transaction
The expression formula that returns the number of weeks that passed since the first transaction

Average number of transactions per week

Create an expression that calculates the average number of transactions a customer made per week in the last 90 days. This expression reuses the aggregate that calculates the number of transactions in the last 90 days and the expression that calculates the number of weeks since the first transaction in the last 90 days.

  1. Go to Analytics icon Analytics > Expressions > New expression.
  2. Enter a meaningful name of the expression.
  3. Leave the expression type at default (Attribute).
  4. Build the following expression formula:
    1. Click the Select node.
    2. From the dropdown list, select Customer.
    3. Click the unnamed node that has been added to the canvas.
    4. Scroll down the page and click Choose attribute.
    5. Search and select the aggregate that calculates the number of transactions.
    6. Next to the expression on the canvas, click the plus button icon.
    7. Select Customer.
    8. Click the unnamed node that has been added to the canvas.
    9. Scroll down the page and click Choose attribute.
    10. Search and select the expression that calculates weeks from first transactions.
    11. Click the mathematical operator between the nodes and change it to a division sign.
  5. Save the expression.
The expression formula that returns the average number of transactions per week
The expression formula that returns the average number of transactions per week

Segment of loyal customers

Create a group of loyal customers. The business asumptions about loyal customers may slightly differ in each organization, they can include the defined number of transactions, the loyalty card, frequent usage of moble application, and so on. Construct the condition of a segmentation in accordance with your requirements for loyal customers.

  1. Go to Analytics icon Analytics > Segmentations > New segmentation.
  2. Enter a meaningful name of the segmentation.
  3. In the condition of the segmentation include customers who according to your busisness assumptions.
    Tip: You can find more information about creating segmentations here.
  4. Save the segmentation.

Create metrics


In this part of the process, prepare metrics which will calculate the qunatiles: 0.80, 0.60, 0.40, 0.20 for the values of the expressions and an aggregate:

Create four metrics for each score (which means that in total you will create 12 metrics). This way, you can distinguish tresholds for Recency, Frequency, and Monetary scores.

Recency score

  1. Go to Analytics icon Analytics > Metrics > New metric.

  2. Enter a meaningful metric name.

  3. Leave the metric kind at default (Simple).

  4. Change the Metric type to Customer.

  5. Change the Aggregator option to Quantile.

  6. Next to the Quantile option, in the text field, enter 0.80.

  7. Click Choose value.

  8. Search and select the expression that returns the number of days that passed since the last transaction.

  9. Click Enable filter.

  10. Click Choose filter.

  11. Search and select the segmentation of loyal customers.

  12. As the logical operator, select Is true.

  13. Confirm the filter settings by clicking Apply.

  14. Using the date picker in the lower-right corner, set the time range to Relative time range > Lifetime.

  15. Save the metric.

  16. Create three metrics with the same settings for the following quantile values: 0.60, 0.40, and 0.20.

    The metric that calculates 0.80 quantile of the expression
    The metric that calculates 0.80 quantile of the expression

Frequency score

  1. Go to Analytics icon Analytics > Metrics > New metric.
  2. Enter a meaningful metric name.
  3. Leave the metric kind at default (Simple).
  4. Change the Metric type to Customer.
  5. Change the Aggregator option to Quantile.
  6. Next to the Quantile option, in the text field, enter 0.20.
  7. Click Choose value.
  8. Search and select the expression that returns the average number of transactions in a week.
  9. Click Enable filter.
  10. Click Choose filter.
  11. Search and select the segmentation of loyal customers.
  12. As the logical operator, select Is true.
  13. Confirm the filter settings by clicking Apply.
  14. Using the date picker in the lower-right corner, set the time range to Relative time range > Lifetime.
  15. Save the metric.
  16. Create three metrics with the same settings for the following quantile values: 0.40, 0.60, and 0.80.
The metric that calculates 0.20 quantile of the expression
The metric that calculates 0.20 quantile of the expression

Monetary score

  1. Go to Analytics icon Analytics > Metrics > New metric.
  2. Enter a meaningful metric name.
  3. Leave the metric kind at default (Simple).
  4. Change the Metric type to Customer.
  5. Change the Aggregator option to Quantile.
  6. Next to the Quantile option, in the text field, enter 0.20.
  7. Click Choose value.
  8. Search and select the aggregate that returns the value of purchases in last 90 days.
  9. Click Enable filter.
  10. Click Choose filter.
  11. Search and select the segmentation of loyal customers.
  12. As the logical operator, select Is true.
  13. Confirm the filter settings by clicking Apply.
  14. Using the date picker in the lower-right corner, set the time range to Relative time range > Lifetime.
  15. Save the metric.
  16. Create three metrics with the same settings for the following quantile values: 0.40, 0.60, and 0.80.
The metric that calculates 0.20 quantile of the expression
The metric that calculates 0.20 quantile of the aggregate

Create a dashboard


In this part of the process, to conveniently preview the results of all metrics you created in the previous part of the process, create a dashboard.

  1. Go to Analytics icon Analytics > Dashboard > New dashboard.
  2. Enter a meaningful name of the dashboard.
  3. Add the 12 metrics you created in the previous part of the process.
    Tip: You can learn more about creating dashboards here.
  4. Save the dashboard.
    The example dashboard
    The example dashboard

Create segmentations


Based on the values returned by the metrics you created before, create three segmentations for Recency, Frequency and Monetary scores. Each of the segmentation contains 5 sub-segmentations. Each sub-segmentation reuses the result of a quantile calculated by the metrics.

The sub-segmentation are named in the following way:

  • For Recency score: 500, 400, 300, 200, 100
Sub-segmentation 500 400 300 200 100
Conditions The value lower than
the 0.20 quantile
The value lower than
the 0.40 quantile but higher than 0.20 quantile
The value lower than
the 0.60 quantile but higher than 0.40 quantile
The value lower than
the 0.80 quantile but higher than 0.60 quantile
The value higer than 0.80
quantile
  • For Frequency score: 50, 40, 30, 20, 10
Sub-segmentation 50 40 30 20 10
Conditions The value higher than
0.80 quantile
The value lower than
0.80 quantile but higher than 0.60 quantile
The value lower than
0.60 quantile but higher than 0.4 quantile
The value lower than
0.40 quantile but higher than 0.20 quantile
The value lower than 0.20
quantile
  • For Monetary score: 5, 4, 3, 2, 1
Sub-segmentation 5 4 3 2 1
Conditions The value higher than
0.80 quantile
The value lower than
0.80 quantile but higher than 0.60 quantile
The value lower than
0.60 quantile but higher than 0.4 quantile
The value lower than
0.40 quantile but higher than 0.20 quantile
The value lower than 0.20
quantile

Customers belong to a specific sub-segmentation under defined circumstances and based on the sub-segmentation classification the overall score will be created, for example, a customer can belong to the following sub-segmentations: 500 (R), 20 (F), 3 (M). In the next part of the process these values will be added in an expression to produce the final RFM score, which in this example will be 523.

Recency

  1. Go to Analytics icon Analytics > Segmentations > New segmentation.
  2. Enter a meaningful name of the segmentation.
  3. As the name of the sub-segmentation, enter 500.
  4. Click Choose filter.
  5. Search and select the expression that returns the number of days since the last transaction.
  6. As the logical operator select Less than.
  7. In the text field, next to the logical operator, enter the number returned by the metrics that calculate the 0.20 quantile. In this use case, the quantile result amounts to 3.89, so the customers who made a transaction less than 3 days after the date of the last transaction in the last 90 days, belong to 500. It means that the R score of the customer is 500, which is the highest.
  8. Click Choose filter.
  9. Select the segment of loyal customers.
  10. Join the two conditions by selecting the AND operator.
  11. Add the rest of sub-segmentations by clicking the Analytics icon icon.
  12. In the conditions of the sub-segmentations:
    • For the 400 sub-segmentation: more than the value of the 0.20 quantile AND less than 0.40 quantile AND segment of loyal customers
    • For the 300 sub-segmentation: more than the value of the 0.40 quantile AND less than 0.60 quantile AND segment of loyal customers
    • For the 200 sub-segmentation: more than the value of the 0.60 quantile AND less than 0.80 quantile AND segment of loyal customers
    • For the 100 sub-segmentation: less than the value of the 0.80 quantile AND segment of loyal customers
    The configuration of the Recency score segmentation
    The configuration of the Recency score segmentation

Frequency

  1. Go to Analytics icon Analytics > Segmentations > New segmentation.
  2. Enter a meaningful name of the segmentation.
  3. As the name of the sub-segmentation, enter 50.
  4. Click Choose filter.
  5. Search and select the expression that returns the average number of transactions per week.
  6. As the logical operator select More than or equal.
  7. In the text field, next to the logical operator, enter the number returned by the metrics that calculate the 0.80 quantile. In this use case, the quantile result amounts to 0.98, so the customers who make more than 0.98 transaction a week in the last 90 days, belong to 50. It means that the F score of the customer is 50, which is the highest.
  8. Click Choose filter.
  9. Select the segment of loyal customers.
  10. Join the two conditions by selecting the AND operator.
  11. Add the rest of sub-segmentations by clicking the Analytics icon icon.
  12. In the conditions of the sub-segmentations:
    • For the 40 sub-segmentation: more than the value of the 0.60 quantile AND less than 0.80 quantile AND segment of loyal customers
    • For the 30 sub-segmentation: more than the value of the 0.40 quantile AND less than 0.60 quantile AND segment of loyal customers
    • For the 20 sub-segmentation: more than the value of the 0.20 quantile AND less than 0.40 quantile AND segment of loyal customers
    • For the 10 sub-segmentation: less than the value of the 0.20 quantile AND segment of loyal customers AND transaction event in last 90 days
    The configuration of the Frequency score segmentation
    The configuration of the Frequency segmentation

Monetary

  1. Go to Analytics icon Analytics > Segmentations > New segmentation.
  2. Enter a meaningful name of the segmentation.
  3. As the name of the sub-segmentation, enter 5.
  4. Click Choose filter.
  5. Search and select the aggregate that returns the value of transactions in last 90 days.
  6. As the logical operator select More than or equal.
  7. In the text field, next to the logical operator, enter the number returned by the metrics that calculate the 0.80 quantile. In this use case, the quantile result amounts to 967,30 PLN, so the customers who spent this amount of money or more in the last 90 days, belong to 5. It means that the M score of the customer is 5, which is the highest.
  8. Click Choose filter.
  9. Select the segment of loyal customers.
  10. Join the two conditions by selecting the AND operator.
  11. Add the rest of sub-segmentations by clicking the Analytics icon icon.
  12. In the conditions of the sub-segmentations:
    • For the 4 sub-segmentation: more than the value of the 0.60 quantile AND less than 0.80 quantile AND segment of loyal customers
    • For the 3 sub-segmentation: more than the value of the 0.40 quantile AND less than 0.60 quantile AND segment of loyal customers
    • For the 2 sub-segmentation: more than the value of the 0.20 quantile AND less than 0.40 quantile AND segment of loyal customers
    • For the 1 sub-segmentation: less than the value of the 0.20 quantile AND segment of loyal customers AND transaction event in the last 90 days.
    The configuration of the Monetary score segmentation
    The configuration of the Monetary segmentation

Create an expression


In this part of the process, create an expression that adds the sub-segmentations a customer belongs to, in order to produce the final RFM score.

  1. Go to Analytics icon Analytics > Expressions > New expression.
  2. Enter a meaningful name of the expression.
  3. Leave the expression type at default (Attribute).
  4. Build the formula of the expression that adds the three segmentations you created in the previous part of the procedure.
    1. Click the Select node.
    2. From the dropdown list, select Customer.
    3. Click the unnamed node that appeared on the canvas.
    4. Scroll down the page and click Choose attribute.
    5. On the dropdown list select the Recency segmentation.
    6. Next to the segmentation added to the canvas, click the plus button.
    7. Repeat steps from 1 to 6 for the Frequency and Monetary segmentations.
    8. Click the mathematical operator between the nodes and change it to a plus sign.
      The configuration of the expression
      The configuration of the expression
  5. Save the expression.
    Result: The table below contains all possible results:
Possible results
111, 112, 113, 114, 115, 121, 122, 123, 124, 125,131, 132, 133, 134, 135, 141, 142, 143, 144, 145, 151, 152, 153, 154, 155, 211, 212, 213, 214, 215, 221, 222, 223, 224, 225, 231, 232, 233, 234, 235, 241, 242, 243, 244, 245, 251, 252, 253, 254, 255, 311, 312, 313, 314, 315, 321, 322, 323, 324, 325, 331, 332, 333, 334, 335, 341, 342, 343, 344, 345, 351, 352, 353, 354, 355, 411, 412, 413, 414, 415, 421, 422, 423, 424, 425, 431, 432, 433, 434, 435, 441, 442, 443, 444, 445, 451, 452, 453, 454, 455, 511, 512, 513, 514, 515, 521, 522, 523, 524, 525, 531, 532, 533, 534, 535, 541, 542, 543, 544, 545, 551, 552, 553, 554, 555

You need to come up with categories of the customers and assign the results to the specific category. Example categories can be: Top customers, Recent customers, Churn risk, Heavy buyers, Lost heavy buyers, Lost customers.

Create a RFM segmentation


In the final part of the process, create a segmentation that contains sub-segments. Each sub-segment represents a category of customers. As the condition for each sub-segmentation, use the expression created in the previous part of the process and define the scores that fall into a particular category.

  1. Go to Analytics icon Analytics > Segmentations > New segmentation.

  2. Enter a meaningful title of the segmentation.

  3. Click Choose filter.

  4. On the dropdown list, search and select the expression created in the previous part of the process.

  5. As the logical operator, select In.

  6. Enter the score that fall into a category.

  7. Click the Analytics icon icon.

  8. Repeat steps from 3 to 7 for the rest of the categories.

    The configuration of the RFM segmentation
    The configuration of the RFM segmentation
  9. Save the segmentation.

    Example preview of the RFM analysis
    Example preview of the RFM analysis

Check the use case set up on the Synerise demo workspace


Check the analytics from our use case in Synerise demo workspace:

  • Aggregate which counts transactions,
  • Aggregate counts first transactions,
  • Aggregate counts last transactions,
  • Aggregate presented monetary value,
  • Expression counts days from last transaction,
  • Expression that calculates how much time passed since the last transaction,
  • Expression that calculates the number of weeks since the first transaction of a customer,
  • Expression that calculates the average number of transactions a customer made per week.

See the metrics which will calculate the qunatiles for the values of the expressions and an aggregate"

Check the dashboard presenting RFM summary.

Check three segments, created in this case:

Check the RFM general score.

If you don’t have access to the Synerise demo workspace, please leave your contact details in this form, and our representative will contact you shortly.

Read more


😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker