
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.  

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-analysis-cover.png" alt="RFM analysis"  class="full no-frame">
</figure>

## 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 some [basic analyses](/use-cases/rfm-analysis#create-a-set-of-basic-analyses) for later use in more complex calculations.
2. Create a [set of metrics](/use-cases/rfm-analysis#create-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.
4. Prepare [segmentations](/use-cases/rfm-analysis#create-segmentations) for Recency, Frequency, and Monetary scores based on the values returned by the metrics you created before. The segments in these segmentations 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](/use-cases/rfm-analysis#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](/use-cases/rfm-analysis#create-a-rfm-segmentation) that contains the segments which correspond to the customer categories (for example, Top customers, Heavy buyers, Lost customers, and so on). Define the range of scores for each category.
7. Create a workflow which automates the process of updating the values of the quantile calculation metrics used in the [Recency](/use-cases/rfm-analysis#recency), [Frequency](/use-cases/rfm-analysis#frequency), and [Monetary](/use-cases/rfm-analysis#monetary) segments. Such automation will ensure that you are always operating with the most up-to-date metrics, maintaining an appropriate range between all segments. 
8. Create a [dashboard](/use-cases/rfm-analysis#create-a-dashboard) to conveniently display the results of the metrics.


   <div class="admonition admonition-note"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

   You can find furhter explanation in the corresponding sections in the article.

   </div></div></div>


## Create a set of basic analyses
----
In this part of the process, you must create a number of analyses which will be reused later in the process.

### Number of transactions

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


<div class="admonition admonition-note"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

The time ranges used in this use case are just an example. Apply such time ranges that suit your business needs.

</div></div></div>



<div class="admonition admonition-tip"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z" /></svg></div><div class="admonition-body"><div class="admonition-content">

You can read more about aggregates [here](/docs/analytics/aggregates).

</div></div></div>


1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > Live Aggregates > Create aggregate**.
2. As the aggregate type, select **Profile**.  
2. Enter a meaningful name of the aggregate.  
3. Set the **Analyze profiles by** option to **Count**.  
4. Click the **Choose event** dropdown list.  
5. From the dropdown list, select the event that signifies a purchase.  
    
   <div class="admonition admonition-tip"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z" /></svg></div><div class="admonition-body"><div class="admonition-content">

   Events may have different labels between workspaces, but you can always find them by their action name (in this step, it’s transaction.charge).

   </div></div></div>
  
9. Using the date picker in the lower-right corner, set the time range to **Lifetime**.  
10. Save the aggregate.

 <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-count-transactions-new.png" alt="The aggregate that returns the number of transactions for a customer" class="full">
    <figcaption> The aggregate that returns the number of transactions for a customer </figcaption>
    </figure> 

### Time of the first purchase

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

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > Live Aggregates > Create aggregate**.
2. As the aggregate type, select **Profile**.  
2. Enter a meaningful name of the aggregate.  
3. Set the **Analyze profiles by** option to **First**.  
4. Click the **Choose event** dropdown list.  
5. From the dropdown list, select the event that signifies a purchase.  
    
   <div class="admonition admonition-tip"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z" /></svg></div><div class="admonition-body"><div class="admonition-content">

   Events may have different labels between workspaces, but you can always find them by their action name (in this step, it’s transaction.charge).

   </div></div></div>
  
6. Click **+ where** button.  
7. On the dropdown list, click <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/threedoticon.png" alt="Three dot icon" class="icon" > > **Specials**.
8. Choose **TIMESTAMP**.  
9. Using the date picker in the lower-right corner, set the time range to **Lifetime**.  
10. Save the aggregate.

  <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-first-transaction-new.png" alt="The aggregate that returns the time of first transaction of a customer" class="full">
    <figcaption> The aggregate that returns the time of first transaction of a customer </figcaption>
    </figure> 

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

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > Live Aggregates > Create aggregate**.
2. As the aggregate type, select **Profile**.  
2. Enter a meaningful name of the aggregate.  
3. Set the **Analyze profiles by** option to **Last**.  
4. Click the **Choose event** dropdown list.  
5. From the dropdown list, select the event that signifies a purchase.  
    
   <div class="admonition admonition-tip"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z" /></svg></div><div class="admonition-body"><div class="admonition-content">

   Events may have different labels between workspaces
       , but you can always find them by their action name (in this step, it’s transaction.charge).

   </div></div></div>
  
6. Click **+ where** button.  
7. On the dropdown list, click <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/threedoticon.png" alt="Three dot icon" class="icon" > > **Specials**.
8. Choose **TIMESTAMP**.  
9. Using the date picker in the lower-right corner, set the time range to **Lifetime**.  
10. Save the aggregate.

 <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-last-transaction-new.png" alt="The aggregate that returns the time of last transaction for a customer" class="full">
    <figcaption> The aggregate that returns the time of last transaction for a customer </figcaption>
    </figure> 

### Value of purchase 

Create the aggregate that returns the total amount of money a single customer spent.  

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > Live Aggregates > Create aggregate**.
2. As the aggregate type, select **Profile**.  
2. Enter a meaningful name of the aggregate.  
3. Set the **Analyze profiles by** option to **Sum**.  
4. Click the **Choose event** dropdown list.  
5. From the dropdown list, select the event that signifies a purchase.  
    
   <div class="admonition admonition-tip"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z" /></svg></div><div class="admonition-body"><div class="admonition-content">

   Events may have different labels between workspaces, but you can always find them by their action name (in this step, it’s transaction.charge).

   </div></div></div>
  
6. Click **+ where** button.  
7. On the dropdown list, select the parameter that signifies the total amount of a transaction, for example, `$totalAmount`
9. Using the date picker in the lower-right corner, set the time range to **Lifetime**.  
10. Save the aggregate.

 <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-monetary-value-new.png" alt="The aggregate that returns the total amount of money a customer spent" class="full">
    <figcaption> The aggregate that returns the total amount of money a customer spent </figcaption>
    </figure> 

### 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](/use-cases/rfm-analysis#time-of-the-last-purchase) in the last 90 days.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > 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:  
    <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-days-from-last-transaction-new.png" alt="The expression formula that returns the number of days that passed since the last transaction" class="full">
    <figcaption> The expression formula that returns the number of days that passed since the last transaction </figcaption>
    </figure> 
    
   <details class="accordion"><summary>Click here to watch the video tutorial</summary><div class="accordion-content"></div></details>
 

    In the formula of the expression, you must deduct the [date of the last transaction](/use-cases/rfm-analysis#time-of-the-last-purchase) 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.

### Number of days since the first transaction

Create an attribute expression that calculates how much time passed since the first transaction. This expression reuses the [aggregate that returns the timestamp of the first transaction](/use-cases/rfm-analysis#time-of-the-first-purchase) in the last 90 days and it will be reused in the [expression that returns the number of weeks](/use-cases/rfm-analysis#weeks-from-the-first-transaction) that passed from the first transaction.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > 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:  
    <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-time-from-first-transaction-new.png" alt="The expression formula that returns the time that passed since the first transaction" class="full">
    <figcaption> The expression formula that returns the time that passed since the first transaction </figcaption>
    </figure>
    
   <details class="accordion"><summary>Click here to watch the video tutorial</summary><div class="accordion-content"></div></details>
  

    In the formula of the expression, you must deduct the [date of the first transaction](/use-cases/rfm-analysis#time-of-the-first-purchase) 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](/use-cases/rfm-analysis#number-of-days-since-the-first-transaction).

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > 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 **Profile**.  
    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](/use-cases/rfm-analysis#number-of-days-since-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.

<figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-weeks-from-first-transaction.png" alt="The expression formula that returns the number of weeks that passed since the first transaction" class="full">
    <figcaption> The expression formula that returns the number of weeks that passed since the first transaction </figcaption>
    </figure>

### 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](/use-cases/rfm-analysis#number-of-transactions) in the last 90 days and the [expression that calculates the number of weeks since the first transaction](/use-cases/rfm-analysis#weeks-from-the-first-transaction) in the last 90 days.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > 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 **Profile**.  
    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](/use-cases/rfm-analysis#number-of-transactions).
    6. Next to the expression on the canvas, click the plus button icon.
    7. Select **Profile**.  
    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](/use-cases/rfm-analysis#weeks-from-the-first-transaction).
    11. Click the mathematical operator between the nodes and change it to a division sign.  
5. Save the expression.

<figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-average-transaction-number.png" alt="The expression formula that returns the average number of transactions per week " class="full">
    <figcaption> The expression formula that returns the average number of transactions per week </figcaption>
    </figure>

## Create metrics
---
In this part of the process, prepare metrics which will calculate the following quantiles: `0.80`, `0.60`, `0.40`, `0.20` for the values of the expressions and an aggregate:
- [the number of days that passed since last transaction](/use-cases/rfm-analysis#time-of-the-last-purchase) (**Recency**)
- [the average number of transactions in a week](/use-cases/rfm-analysis#average-number-of-transactions-per-week) (**Frequency**)
- [total value of transactions in last 90 days](/use-cases/rfm-analysis#value-of-purchase) (**Monetary**) 

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 <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/decision-hub-icon.svg" alt="Decision Hub icon" class="icon" > **Decision Hub > Metrics > New metric**.  
2. Enter a meaningful metric name.
3. Leave the metric kind at default (**Simple**).
4. Change the **Metric** type to **Profile**.  
5. Change the **Aggregator** option to **Quantile**. 
5. Next to the **Quantile** option, in the text field, enter `0.80`.
6. Click **Choose value**.
7. Search and select the [expression that returns the number of days that passed since the last transaction](/use-cases/rfm-analysis#number-of-days-since-last-transaction).
8. Click **Enable filter**.
9. Click **Choose filter**.
10. Search and select the **transaction.charge** event.
11. Set the time range to **Lifetime**.
12. Confirm the filter settings by clicking **Apply**.
13. Save the metric.  
14. Create three metrics with the same settings for the following quantile values: `0.60`, `0.40`, and `0.20`. 

    <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-recency-score.png" alt="The metric that calculates 0.80 quantile of the expression" class="full">
    <figcaption> The metric that calculates 0.80 quantile of the expression </figcaption>
    </figure>

### Frequency score

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/decision-hub-icon.svg" alt="Decision Hub icon" class="icon" > **Decision Hub > Metrics > New metric**.  
2. Enter a meaningful metric name.
3. Leave the metric kind at default (**Simple**).
4. Change the **Metric** type to **Profile**.  
5. Change the **Aggregator** option to **Quantile**. 
5. Next to the **Quantile** option, in the text field, enter `0.20`.
6. Click **Choose value**.
7. Search and select the [expression that returns the average number of transactions in a week](/use-cases/rfm-analysis#average-number-of-transactions-per-week).
8. Click **Enable filter**.  
9. Click **Choose filter**.
10. Search and select the **transaction.charge** event.
11. Set the time range to **Lifetime**.
12. Confirm the filter settings by clicking **Apply**.  
13. Save the metric.  
14. Create three metrics with the same settings for the following quantile values: `0.40`, `0.60`, and `0.80`. 

 <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-frequency-score.png" alt="The metric that calculates 0.20 quantile of the expression" class="full">
    <figcaption> The metric that calculates 0.20 quantile of the expression </figcaption>
    </figure>

### Monetary score

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/decision-hub-icon.svg" alt="Decision Hub icon" class="icon" > **Decision Hub > Metrics > New metric**.  
2. Enter a meaningful metric name.
3. Leave the metric kind at default (**Simple**).
4. Change the **Metric** type to **Profile**.  
5. Change the **Aggregator** option to **Quantile**. 
5. Next to the **Quantile** option, in the text field, enter `0.20`.
6. Click **Choose value**.
7. Search and select the [aggregate that returns the value of purchases in last 90 days](/use-cases/rfm-analysis#value-of-purchase).
8. Click **Enable filter**.  
9. Click **Choose filter**.
10. Search and select the **transaction.charge** event.
11. Set the time range to **Lifetime**.
12. Confirm the filter settings by clicking **Apply**.  
13. Save the metric.  
14. Create three metrics with the same settings for the following quantile values: `0.40`, `0.60`, and `0.80`. 

   <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-monetary-score.png" alt="The metric that calculates 0.20 quantile of the expression" class="full">
    <figcaption> The metric that calculates 0.20 quantile of the aggregate </figcaption>
    </figure>

## 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 segments. Each segment reuses the result of a quantile calculated by the metrics.

The segments are named in the following way:
- For Recency score: 500, 400, 300, 200, 100  

| Segment       | 500                               | 400                               | 300                              | 200                               | 100                                   |
|---------|-----------------------------------|-----------------------------------|----------------------------------|-----------------------------------|---------------------------------------|
| Conditions | The value lower than <br>the 0.20 quantile | The value lower than<br>the 0.40 quantile but higher than 0.20 quantile | The value lower than<br>the 0.60 quantile but higher than 0.40 quantile | The value lower than<br>the 0.80 quantile but higher than 0.60 quantile | The value higer than 0.80 <br>quantile |

- For Frequency score: 50, 40, 30, 20, 10


| Segment       | 50                               | 40                               | 30                              | 20                               | 10                                   |
|---------|-----------------------------------|-----------------------------------|----------------------------------|-----------------------------------|---------------------------------------|
| Conditions | The value higher than <br> 0.80 quantile | The value lower than<br> 0.80 quantile but higher than 0.60 quantile | The value lower than<br> 0.60 quantile but higher than 0.4 quantile | The value lower than<br> 0.40 quantile but higher than 0.20 quantile | The value lower than 0.20 <br>quantile |
- For Monetary score: 5, 4, 3, 2, 1

| Segment         | 5                               | 4                               | 3                              | 2                               | 1                                   |
|---------|-----------------------------------|-----------------------------------|----------------------------------|-----------------------------------|---------------------------------------|
| Conditions | The value higher than <br> 0.80 quantile | The value lower than<br> 0.80 quantile but higher than 0.60 quantile | The value lower than<br> 0.60 quantile but higher than 0.4 quantile | The value lower than<br> 0.40 quantile but higher than 0.20 quantile | The value lower than 0.20 <br>quantile |

Customers belong to a specific segment under defined circumstances and based on the segment classification the overall score will be created, for example, a customer can belong to the following segments: 500 (R), 20 (F), 3 (M). In the next part of the process, these values will be added in an [expression](/use-cases/rfm-analysis#create-an-expression) to produce the final RFM score, which in this example will be 523.


### Recency 

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/decision-hub-icon.svg" alt="Decision Hub icon" class="icon" > **Decision Hub > Segmentations > New segmentation**.
2. Enter a meaningful name of the segmentation. 
3. As the name of the segment, enter `500`.  
4. Click **Add condition**.
5. Search and select the [expression that returns the number of days since the last transaction](/use-cases/rfm-analysis#number-of-days-since-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 `43.3`, so the customers who made a transaction less than 43 days after the date of the last transaction, belong to 500. It means that the R score of the customer is 500, which is the highest.
6. Add the rest of segments by clicking the <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/docs/analytics/_gfx/plus-button.png" alt="Plus button icon" class="icon" > icon.
7. For the following segments, add the conditions listed below:  
    - For the 400 segment: more than the value of the `0.20` quantile **AND** less than `0.40` quantile 
    - For the 300 segment: more than the value of the `0.40` quantile **AND** less than `0.60` quantile 
    - For the 200 segment: more than the value of the `0.60` quantile **AND** less than `0.80` quantile 
    - For the 100 segment: less than the value of the `0.80` quantile **AND** segment of loyal customers **AND** add the **transaction.charge** event with the **Lifetime** time range. 
    <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-recency-score-segmentationv2.png" alt="The configuration of the Recency score segmentation" class="full">
    <figcaption> The configuration of the Recency score segmentation </figcaption>
    </figure>

### Frequency

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/decision-hub-icon.svg" alt="Decision Hub icon" class="icon" > **Decision Hub > Segmentations > New segmentation**.
2. Enter a meaningful name of the segmentation. 
3. As the name of the segment, enter `50`.  
4. Click **Add condition**.
5. Search and select the [expression that returns the average number of transactions per week](/use-cases/rfm-analysis#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.4`, so the customers who make more than 0.4 transaction a week, belong to 50. It means that the F score of the customer is 50, which is the highest.
6. Add the rest of segments by clicking the <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/docs/analytics/_gfx/plus-button.png" alt="Plus button icon" class="icon" > icon.
7. For the following segments, add the conditions listed below: 
    - For the 40 segment: more than the value of the `0.60` quantile **AND** less than `0.80` quantile 
    - For the 30 segment: more than the value of the `0.40` quantile **AND** less than `0.60` quantile 
    - For the 20 segment: more than the value of the `0.20` quantile **AND** less than `0.40` quantile 
    - For the 10 segment: less than the value of the `0.20` quantile **AND** segment of loyal customers **AND** add the **transaction.charge** event with the **Lifetime** time range. 
    <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-frequency-score-segmentationv2.png" alt="The configuration of the Frequency score segmentation" class="full">
    <figcaption> The configuration of the Frequency segmentation </figcaption>
    </figure>

### Monetary

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/decision-hub-icon.svg" alt="Decision Hub icon" class="icon" > **Decision Hub > Segmentations > New segmentation**.
2. Enter a meaningful name of the segmentation. 
3. As the name of the segment, enter `5`.  
4. Click **Add condition**.
5. Search and select the [aggregate that returns the value of transactions](/use-cases/rfm-analysis#value-of-purchase).
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 `2243 PLN`, so the customers who spent this amount of money or more, belong to 5. It means that the M score of the customer is 5, which is the highest.
6. Add the rest of segments by clicking the <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/docs/analytics/_gfx/plus-button.png" alt="Plus button icon" class="icon" > icon.
7.  For the following segments, add the conditions listed below: 
    - For the 4 segment: more than the value of the `0.60` quantile **AND** less than `0.80` quantile 
    - For the 3 segment: more than the value of the `0.40` quantile **AND** less than `0.60` quantile
    - For the 2 segment: more than the value of the `0.20` quantile **AND** less than `0.40` quantile 
    - For the 1 segment: less than the value of the `0.20` quantile **AND** add the **transaction.charge** event with the **Lifetime** time range. 
    <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-monetary-score-segmentationv2.png" alt="The configuration of the Monetary score segmentation" class="full">
    <figcaption> The configuration of the Monetary segmentation </figcaption>
    </figure>

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

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > 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](/use-cases/rfm-analysis#create-segmentations) you created in the previous part of the procedure.  
    1. Click the **Select** node.  
    2. From the dropdown list, select **Profile**.  
    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](/use-cases/rfm-analysis#recency) segmentation.
    6. Next to the segmentation added to the canvas, click the plus button.
    6. Repeat steps from 1 to 6 for the [Frequency](/use-cases/rfm-analysis#frequency) and [Monetary](/use-cases/rfm-analysis#monetary) segmentations.  
    7. Click the mathematical operator between the nodes and change it to a plus sign.  
       <figure>
        <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-expression-rfm-score.png" alt="The configuration of the expression" class="full">
        <figcaption> The configuration of the expression </figcaption>
        </figure> 
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 segments. Each segment represents a category of customers. As the condition for each segment, use the [expression created in the previous part of the process](/use-cases/rfm-analysis#create-an-expression) and define the scores that fall into a particular category.  

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/decision-hub-icon.svg" alt="Decision Hub icon" class="icon" > **Decision Hub > Segmentations > New segmentation**.  
2. Enter a meaningful title of the segmentation.  
3. Click **Add condition**.
4. On the dropdown list, search and select the [expression created in the previous part of the process](/use-cases/rfm-analysis#create-an-expression).  
5. As the logical operator, select **In**. 
6. Enter the score that fall into a category. 
7. Click the <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/docs/analytics/_gfx/plus-button.png" alt="Plus button icon" class="icon" > icon.
7. Repeat steps from 3 to 7 for the rest of the categories.  
    <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/final-rfm-segmentation.png" alt="The configuration of the RFM segmentation" class="full">
    <figcaption> The configuration of the RFM segmentation </figcaption>
    </figure>
8. Save the segmentation.   

    <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/final-rfm-segmentation-preview.png" alt="Example preview of the RFM analysis" class="full">
    <figcaption> Example preview of the RFM analysis </figcaption>
    </figure>

## Create a workflow 
---
Create a workflow which automates the process of updating the values of the quantile calculation metrics used in the [Recency](/use-cases/rfm-analysis#recency), [Frequency](/use-cases/rfm-analysis#frequency), and [Monetary](/use-cases/rfm-analysis#monetary) segmentations. These segmentations will be updated using webhooks, where each webhook is dedicated to updating the value of the metrics in one segmentation.

Before you start creating a workflow, create a test user that you will later use in the trigger node. All webhook responses will be sent to this profile, this way you will be able to check if the update was successful.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/automation-hub-icon.svg" alt="Automation Hub icon" class="icon" > **Automation Hub > Workflows > New workflow**.  
2. Enter the name of the workflow.

### Define the Audience node
---
Choose the **Audience** node as the trigger. In this step, you will select a test user for whom the automation will be run. 

1. Start the workflow with the **Audience** node.
2. In the configuration of the node, set the **Run trigger** option to **repeatable**.
3. Set the interval to 1 per day.
4. Choose the day and time when the process starts. 
5. Select the time zone.
6. In **Define audience**, choose **New Audience** and click **Define conditions**.
    1. As the first condition, from **Choose filter** dropdown menu, choose `Email address` attribute. 

       <div class="admonition admonition-note"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

       You may have a different naming for the attribute responsible for the email address. Choose the attribute you use for this purpose.

       </div></div></div>

    2. From the **Choose operator** dropdown list, select **Equal**.
    3. In the right field, enter the email address of your test user. 
    4. Click **Apply**.
7. Add the **Split Path** node. 

### Outgoing Integration
---
1. Add the **Outgoing Integration** node, which will update the value of metrics used in the [Recency score](/use-cases/rfm-analysis#recency) segmentation. 
4. In the configuration of the node:  
    1. Change the webhook type to **Custom**.
    2. As the connection type, select **API Key**.
    3. Click **Select connection** and select a connection.
        If you want to create a connection, click **Add connection** and [create it](/docs/automation/actions/webhook-node#set-up-a-connection).
    1. Enter the title of the **Outgoing Integration** node. 
    2. In the **Webhook name** field, enter the value of the `name` parameter of the event generated by this node.
    3. In **Webhook event name**, click **Create event** and create a new event:
        1. As **Name**, enter `rfm.reportGenerated`
        2. As **Display name**, enter `RFM report generated`  
            
       <div class="admonition admonition-tip"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z" /></svg></div><div class="admonition-body"><div class="admonition-content">

       In this use case, you will create 3 nodes. If you want to differentiate between the events they generate, you can set different webhook names and/or event names for each of them.

       </div></div></div>

    2. Select the **PUT** method.
    3. In the URL of the endpoint, enter the endpoint for the segmentation update: `https://api.synerise.com/analytics/analytics/v2/segmentations/f08a0f4d-4209-40cc-bfe9-4734cd9e0db9`.
    4. Replace the segmentation ID in this endpoint (`f08a0f4d-4209-40cc-bfe9-4734cd9e0db9`) with the ID of the Recency score segmentation.
    5. Enter the body of the request.  
    In the body, you need to add the payload of the segmentation you want to update. To get the payload perform the following steps:
        1. Open the respective segmentation.
        2. Open console and go to the Network tab.
        3. Refresh the page.
        4. Search for preview in the Network.
        5. Right click and copy the object. 

           <details class="accordion"><summary>Click here to see the console view</summary><div class="accordion-content"><figure> <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/network-rfm.gif" alt="How to copy an object of segmentation" class="full"> <figcaption> How to copy an object of segmentation </figcaption> </figure></div></details>
 
        6. In the copied body replace all constant values with the dynamic values of relevant metrics.   
        Example:   
        You have the folowing constant: "constant": `43.3`   
       `43.3` should be replaced in this case with the relevant metric ID. You can additionally round the value of the metric to three decimal places. The final appearance of the substituted constant will look as follows:   

<pre><code class="language-json">"constant":  {% metricsvar  metric_id:97488c6a-746e-42fc-a1ca-b2fb4b8dfa94%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %}</code></pre>


<details class="accordion"><summary>Click here to see the example of body request for the Recency segment</summary><div class="accordion-content"><pre><code class="language-json">{ "analysis": { "title": "[UC] RFM - Recency Score", "description": "", "segments": [ { "title": "500", "description": "", "filter": { "matching": true, "expressions": [ { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "LESS", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:97488c6a-746e-42fc-a1ca-b2fb4b8dfa94%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } } ], "expression": { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "LESS", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:97488c6a-746e-42fc-a1ca-b2fb4b8dfa94%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } } }, "profileMetrics": [] }, { "title": "400", "description": "", "filter": { "matching": true, "expressions": [ { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "MORE_OR_EQUAL", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:97488c6a-746e-42fc-a1ca-b2fb4b8dfa94%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } }, { "type": "OPERATOR", "logic": "AND" }, { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "LESS", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:e571679c-0f04-466f-aa43-ff6d5023bb09%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } } ], "expression": { "type": "FUNCTION", "function": "AND", "arg1": { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "LESS", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:e571679c-0f04-466f-aa43-ff6d5023bb09%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } }, "arg2": { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "MORE_OR_EQUAL", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:97488c6a-746e-42fc-a1ca-b2fb4b8dfa94%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } } } }, "profileMetrics": [] }, { "title": "300", "description": "", "filter": { "matching": true, "expressions": [ { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "MORE_OR_EQUAL", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:e571679c-0f04-466f-aa43-ff6d5023bb09%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } }, { "type": "OPERATOR", "logic": "AND" }, { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "LESS", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:8031ccf4-2444-42bf-8eba-ba61d952d52f%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } } ], "expression": { "type": "FUNCTION", "function": "AND", "arg1": { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "LESS", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:8031ccf4-2444-42bf-8eba-ba61d952d52f%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } }, "arg2": { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "MORE_OR_EQUAL", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:e571679c-0f04-466f-aa43-ff6d5023bb09%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } } } }, "profileMetrics": [] }, { "title": "200", "description": "", "filter": { "matching": true, "expressions": [ { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "MORE_OR_EQUAL", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:8031ccf4-2444-42bf-8eba-ba61d952d52f%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } }, { "type": "OPERATOR", "logic": "AND" }, { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "LESS", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:fb1c9bff-ce29-42c0-93ee-b56f092ae03f%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } } ], "expression": { "type": "FUNCTION", "function": "AND", "arg1": { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "LESS", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:fb1c9bff-ce29-42c0-93ee-b56f092ae03f%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } }, "arg2": { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "MORE_OR_EQUAL", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:8031ccf4-2444-42bf-8eba-ba61d952d52f%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } } } }, "profileMetrics": [] }, { "title": "100", "description": "", "filter": { "matching": true, "expressions": [ { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "MORE_OR_EQUAL", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:fb1c9bff-ce29-42c0-93ee-b56f092ae03f%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } }, { "type": "OPERATOR", "logic": "AND" }, { "name": "", "type": "FUNNEL", "matching": true, "funnel": { "title": "unnamed", "completedWithin": {}, "dateFilter": { "type": "ABSOLUTE" }, "steps": [ { "action": { "id": 68600, "name": "transaction.charge" }, "title": "Unnamed Step", "expressions": [], "eventName": "transaction.charge" } ], "exact": false } } ], "expression": { "type": "FUNCTION", "function": "AND", "arg1": { "name": "", "type": "FUNNEL", "matching": true, "funnel": { "title": "unnamed", "completedWithin": null, "dateFilter": { "type": "ABSOLUTE" }, "steps": [ { "action": { "id": 68600, "name": "transaction.charge" }, "title": "Unnamed Step", "expressions": [], "eventName": "transaction.charge" } ], "exact": false } }, "arg2": { "name": "", "type": "ATTRIBUTE", "matching": true, "attribute": { "expressions": [ { "constraint": { "type": "NUMBER_ONE", "logic": "MORE_OR_EQUAL", "value": { "type": "CONSTANT", "constant": {% metricsvar metric_id:fb1c9bff-ce29-42c0-93ee-b56f092ae03f%}{{ metric_result|round(3,'floor') }} {% endmetricsvar %} } }, "attribute": { "type": "EXPRESSION", "id": "73d13360-2074-463c-9978-79861889dff0" } } ] } } } }, "profileMetrics": [] } ], "unique": true }, "allowNull": true }</code></pre></div></details>
 

<div class="admonition admonition-note"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

This is just an example of the body we are using in this use case, and it contains all the metrics IDs that were created in the previous steps. If your analytics settings differ from the configuration shown in this use case, you will have a different body that matches your custom settings.

</div></div></div>

    3. Click **Apply**.
<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-outgoing-integration.png" alt="The view of the Outgoing Integration node configuration"  class="large">
<figcaption>Configuration of the Outgoing Integration node</figcaption>
</figure> 

Configure two **Outgoing Integration** nodes for the remaining Frequency and Monetary segments. Follow the steps described for the configuration of the **Outgoing Integration** node for the Recency score segmantation, but make sure to adjust the configuration for each specific segment. 

Add the **Merge Paths** node and the **End** node. 

The workflow continuously updates the metrics in the segmentations at a set frequency, ensuring that all segmentations remain up-to-date.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-update-workflow.png" alt="Final workflow setup view"  class="full">
<figcaption>Final workflow setup view</figcaption>
</figure> 

## 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 <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/decision-hub-icon.svg" alt="Decision Hub icon" class="icon" > **Decision Hub > Dashboard > New dashboard**.  
2. Enter a meaningful name of the dashboard.
3. Add all metrics you created earlier in the process.  
    
   <div class="admonition admonition-tip"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z" /></svg></div><div class="admonition-body"><div class="admonition-content">

   You can learn more about creating dashboards [here](/docs/analytics/analytics-dashboard/creating-dashboards).

   </div></div></div>

4. Save the dashboard.  
    <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/rfm-dashboard.png" alt="The example dashboard" class="full">
    <figcaption> The example dashboard </figcaption>
    </figure>

## Check the use case set up on the Synerise demo workspace
---

Check the analytics from our use case in Synerise demo workspace:
- [Aggregate](https://app.synerise.com/analytics/aggregates/603cb871-beb7-3f40-abbd-6cd59c1e7e41) which counts transactions,
- [Aggregate](https://app.synerise.com/analytics/aggregates/85043c5b-a23a-39c6-b95b-9a8680eb20cb) counts first transactions,
- [Aggregate](https://app.synerise.com/analytics/aggregates/64dd4cc6-f45d-31a0-b789-8c2eeb17a72f) counts last transactions, 
- [Aggregate](https://app.synerise.com/analytics/aggregates/ca3285c4-23f4-3b30-a849-fe29517e2323) presented monetary value,
- [Expression](https://app.synerise.com/analytics/expressions/73d13360-2074-463c-9978-79861889dff0) counts days from last transaction, 
- [Expression](https://app.synerise.com/analytics/expressions/6fe20450-5bbb-4cb1-9977-8c49f09effc7) that calculates how much time passed since the first transaction,
- [Expression](https://app.synerise.com/analytics/expressions/5d9a091c-727a-4efe-b95e-74edae60653c) that calculates the number of weeks since the first transaction of a customer,
- [Expression](https://app.synerise.com/analytics/expressions/f9345935-d637-486a-b802-f533148b2312) 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"
- [Metric 1](https://app.synerise.com/analytics/metrics/fb1c9bff-ce29-42c0-93ee-b56f092ae03f),[Metric 2](https://app.synerise.com/analytics/metrics/8031ccf4-2444-42bf-8eba-ba61d952d52f),[Metric 3](https://app.synerise.com/analytics/metrics/e571679c-0f04-466f-aa43-ff6d5023bb09),[Metric 4](https://app.synerise.com/analytics/metrics/97488c6a-746e-42fc-a1ca-b2fb4b8dfa94), counting the number of days that passed since last transaction (Recency),
- [Metric 1](https://app.synerise.com/analytics/metrics/7976c8ab-8047-42d1-8eba-8075d1453e94),[Metric 2](https://app.synerise.com/analytics/metrics/31cac7c2-5e56-4937-80fc-5fbc04ef3b14),[Metric 3](https://app.synerise.com/analytics/metrics/68749154-dea2-4947-91a1-8cf01700f84c),[Metric 4](https://app.synerise.com/analytics/metrics/da817b2a-ce02-4e41-a740-a19061c3e17f), counting the average number of transactions in a week (Frequency)
- [Metric 1](https://app.synerise.com/analytics/metrics/430d45b3-6bde-474e-9b6a-86c0554e4d50),[Metric 2](https://app.synerise.com/analytics/metrics/028a3c2a-06ef-40c2-a7fb-8b0fe7667db7),[Metric 3](https://app.synerise.com/analytics/metrics/804ce3bc-73ad-415d-9a7e-dcb53b78b068),[Metric 4](https://app.synerise.com/analytics/metrics/9dc245b1-014c-47f4-93e6-afc42e8f9ab6), counting total value of transactions in last 90 days (Monetary).

Check the [dashboard](https://app.synerise.com/analytics/dashboards/6e956c95-27fb-418b-92f1-da45a89291d3) presenting RFM summary.

Check three segments, created in this case:
- Segmentation - [Recency](https://app.synerise.com/analytics-v2/segmentations/f08a0f4d-4209-40cc-bfe9-4734cd9e0db9),
- Segmentation - [Frequency](https://app.synerise.com/analytics-v2/segmentations/280bd3dd-2000-4fc0-8c29-89f8403a255b),
- Segmentation - [Monetary](https://app.synerise.com/analytics-v2/segmentations/674c7467-d96e-4139-9fa8-eb2506caf212).

Check the [RFM general score](https://app.synerise.com/analytics/expressions/70716383-93cf-479c-99f0-15ad4c826472) and [RFM segmentation](https://app.synerise.com/analytics-v2/segmentations/bcb2ceb6-fa7d-40ec-a6d2-e2e5573e3995).

Check the [workflow](https://app.synerise.com/automations/automation-diagram/cdcf3c3f-1f28-4fb2-86f0-ed49729ba4a2). 

If you’re our partner or client, you already have automatic access to the **Synerise Demo workspace (1590)**, where you can explore all the configured elements of this use case and copy them to your workspace.  

If you’re not a partner or client yet, we encourage you to fill out the contact [form](https://demo.synerise.com/request) to schedule a meeting with our representatives. They’ll be happy to show you how our demo works and discuss how you can apply this use case in your business.

## Read more
---
- [Aggregates](/docs/analytics/aggregates)
- [Dashboards](/docs/analytics/analytics-dashboard)
- [Expressions](/docs/analytics/expressions)
- [Metrics](/docs/analytics/metrics)
- [Segmentation](/docs/analytics/segmentations)