
In order to better match the offer with the customer's needs, a company needs to conduct an in-depth analysis of the customers' behavior and buying habits on its website. Knowing what products have been purchased as part of a promotion can prove to be very important and beneficial and can be used later while creating different campaigns. 

## Prerequisites 
---
- A [tracking code](/developers/web/installation-and-configuration) implemented into the website. 
- Send information about transactions through [SDK](/developers/web/transactions-sdk) or [API](https://developers.synerise.com/DataManagement/DataManagement.html#operation/CreateATransaction).

## Process
---

In this use case, you will go through the following steps:
1. [Create an expression](/use-cases/create-event-attribute#create-an-expression).
2. [Create a metric](/use-cases/create-event-attribute#create-a-metric).
3. [Create segmentation](/use-cases/create-event-attribute#create-a-segmentation).
4. [Create report](/use-cases/create-event-attribute#create-a-report).

## Create an expression
---

After a purchase is made, the **product.buy** event appears in the customer's profile. This event contains two parameters: **product:price:amount** - describing the original price of the product and **$finalUnitPrice** - describing the final price of the product. The transaction event does not indicate whether the purchased product was covered by a promotion (unless such a parameter has been implemented into the workspace).

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/product.buy_event.png" class="medium" alt="Example of the product.buy event">
<figcaption>Example of the product.buy event</figcaption>
</figure>

Using Decision Hub, you can create an event expression that deducts the price of the purchased product from the regular price. 

Create an expression that calculates the difference between the initial and the final price of the product. 

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 > Expression > New expression**. 
2. Enter the name of the expression. 
3. Set the Expression for option to **Event**. 
4. From the dropdown list, select **Bought products**. 
5. Click the **unnamed** node.
6. From the **Choose attribute** dropdown list, select **product:price:amount**.
7. Click the plus icon. 
8. From the dropdown list, select **Event attribute**. 
9. From the **Choose attribute** dropdown list, select **$finalUnitPrice**.    
10. Change the mathematical operator between these two parameters to minus. 
11. Save the expression. 

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/formula_of_the_expression.png" class="medium" alt="Formula of the expression">
<figcaption>Formula of the expression</figcaption>
</figure>

## Create a metric
---

In this part of the process, you create metrics to see how many products were purchased at a discount. This metric will include the [expression](/use-cases/create-event-attribute#create-an-expression) - if the result of this expression is greater than 0, it means that the product was bought at a discount.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/decision-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Decision Hub > Metrics > New metric**.
2. Enter a meaningful metric name.
3. Leave the metric kind at default (**Simple**).
4. As the aggregator type, select **Sum**.
5. Select the **Bought product** event.
6. Add the **$quantity** parameter.
7. Select the **where** input that appeared on the canvas.
8. Select the expression created in the [previous step](/use-cases/create-event-attribute#create-an-expression).
8. Choose the **More than** number operator.
9. Keep clicking the icon next to the logical operator until you get **#** icon.
10. In the blank field, enter `0`.
11. Select the date range of the metric (for example, last 30 days)
11. Save the metric.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/bought-products-metrics.png" class="large" alt="Metiric configuration">
<figcaption>Metric configuration</figcaption>
</figure>

## Create a segmentation
---
Create a segmentation to see how many customers bought discounted products.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/decision-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Decision Hub > Segmentation > New Segmentation**.
2. Enter the name of segmentation.
3. On the canvas, click **Choose filter**.
4. From the dropdown list, select the **Bought product** event.
5. Select the **where** input that appeared on the canvas.
6. Select the expression created in the [previous step](/use-cases/create-event-attribute#create-an-expression).
7. Choose the **More than** number operator.
8. Keep clicking the icon next to the logical operator until you get **#** icon.
9. In the blank field, enter `0`.
10. Select the date range of the segmentation (for example, last 30 days).
11. Save the segmentation.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/segment_configuration.png" class="large" alt="Segment configuration">
<figcaption>Segment configuration</figcaption>
</figure>

## Create a report
---

In this part of the process, create a report to clearly show the most frequently purchased discounted products, displaying the product parameters that interest you the most (in our example, we display the product names). 

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/decision-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Decision Hub > Report > New report**.
2. Enter the name of the report.
3. Select the metric you created in [this part](/use-cases/create-event-attribute#create-a-metric) of the process.
4. From the **Range** dropdown list, select the number of top (the most frequently bought products) to be shown in the preview of the report. 
5. In the **Dimension** section, choose a parameter from **product.buy** suggesting what the product is. Among the most common parameters, you can choose **$name** or **$sku**.
6. In the date range, select the time that will be analyzed. 

   <div class="admonition admonition-important"><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="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

   Select the same date range as you selected for the metric and the segmentation.

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

7. Save the report.
8. Click preview to see the results.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/bought_product_report.png" class="medium" alt="Segment configuration">
<figcaption>The configuration of report with products bought on promotion</figcaption>
</figure>

The report will return information about how many, for example, XYZ shoes were purchased at a discount.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/bought_product_report_preview.png" class="medium" alt="Segment configuration">
<figcaption>Report preview</figcaption>
</figure>

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

You can find the analyses created in this use case in our Synerise Demo profile at the following links:
- [expression](https://app.synerise.com/analytics/expressions/ca0777e4-19c3-4c1d-84a3-e5d439dc7184),  
- [metric](https://app.synerise.com/analytics/metrics/9b948b8c-8728-42a7-b4e4-2526be5d151f),  
- [segmentation](https://app.synerise.com/analytics/segmentations/4f4722e9-2b80-4dcb-a483-98f11e1bd812),  
- [report](https://app.synerise.com/analytics/reports/883d2dc2-b438-487c-8aee-7c9ee65911e9).

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
---
- [Expressions](/docs/analytics/expressions)
- [Metrics](/docs/analytics/metrics)
- [Segmentation](/docs/analytics/segmentations)