
Price usually turns out to be one of the key factors that influences a customer's final purchase decision. Customers who are more sensitive to price are inclined to postpone or even abandon a purchase if the price offered is not satisfactory to them. Therefore, it is worth informing price-conscious shoppers about price reductions when they occur, which can influence their purchase intentions. It's also a great reminder for impulsive online browsers that can trigger the urge to buy.

This use case describes an example of a price drop alert campaign that you can implement in your business. The described scenario involves sending customers products at a discounted price that the customer previously added to favorites and did not finalize the purchase. 

## Prerequisites 
---
- Implement a [custom event](https://developers.synerise.com/DataManagement/DataManagement.html#operation/CustomEvent) of adding products to favorites. In this use case, this event is named `product.addToFavorites`.
- [Create item catalog](/docs/ai-hub/recommendations-v2/item-feed-requirements) containing information on the actual price of products. 
- [Create an email template](/docs/campaign/e-mail/creating-email-templates) to be used in the price drop campaign. 

## Process
---
1. [Create a product.priceDrop event](/use-cases/price-drop-alert#create-a-productpricedrop-event)
2. [Create an aggregate that collects sku of recently purchased products](/use-cases/price-drop-alert#create-an-aggregate-that-collects-sku-of-recently-purchased-products)
3. [Create an aggregate that collects product sku's added by the users to their favorites](/use-cases/price-drop-alert#create-an-aggregate-that-returns-sku-of-discounted-products-added-to-favorites)
4. [Create an aggregate that collects the latest prices of products added by users to their favorites](/use-cases/price-drop-alert#create-an-aggregate-that-collects-the-latest-prices-of-products-added-by-users-to-their-favorites)
5. [Create an aggregate that collects the last sku's of products received by users with a discounted price](/use-cases/price-drop-alert#create-an-aggregate-that-collects-the-last-skus-of-products-received-by-users-with-a-discounted-price)
6. [Create a workflow](/use-cases/price-drop-alert#create-a-workflow)

## Create a product.priceDrop event
---
In this part of the process create the **product.priceDrop** event, which will later be used in aggregate and workflow.

1.  Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/data-modeling-hub-icon.svg" alt="Data Modeling Hub icon" class="icon"> **Data Modeling Hub > Events**.
2. To create and describe new event in the system click **Add event** option. 
3. Define the name of the event. In our case, the event is called **product.priceDrop**.  
    In the API and SDK, this parameter is usually called "action" or "action name".
4. Optionally, define a human-friendly display name that will be shown in **Data Modeling Hub** and **Decision Hub**.
5. Optionally, describe the event.
6. Enable the **Make this event available to anonymous profiles without JWT** toggle.
7. **Apply** all settings. 
8. In the list of events, find the event you just created. 
9. On the right side of the screen, click **Add property**.
10. In the **Source parameter** field, enter the name of the parameter - `sku`.
11. In the **Property name** field, enter a human-readable label for display in the Synerise platform.
12. Optionally, in the **Description** field, you can add an explanation about the purpose of this parameter. 
13. To complete the process, click **Save**.  

## Create an aggregate that collects sku of recently purchased products
---
This aggregate will be used in the next part of the process to exclude products that the user has already bought.

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 the name of the aggregate.
3. Click **Analyze profiles by** and select **Last multi** and size: **100**.
4. Enable **Consider only distinct occurrences of the event parameter**.
5. From the **Choose event** dropdown list, select the **product.buy** event.
6. As the event parameter, select **sku**.
7. Define the period from which the aggregate will collect products from the event to the last **30 days**. 
8. Save the aggregate.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/last-purch-sku.png" class="full" alt="Configuration of the aggregate">
<figcaption>Configuration of the aggregate</figcaption>
</figure>

## Create an aggregate that returns SKU of discounted products added to favorites
---
This aggregate will be used in the further part of the process. The result of this aggregate will be filtered to prevent sending notifications about discounts on the same favorite items.

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 the name of the aggregate.
3. Click **Analyze profiles by** and select **Last multi** and size: **100**.
5. From the **Choose event** dropdown list, select the **product.addToFavorites** event.
6. As the event parameter, select **sku**.
7. Click **+ where** button.
8. From the **Choose parameter** dropdown list, select the **sku** parameter.
9. From the **Choose operator** dropdown list, select **Not in Array**.
10. From the **Choose value** dropdown list, select the aggregate you created in the [previous step](/use-cases/price-drop-alert#create-an-aggregate-that-collects-sku-of-recently-purchased-products). 
11. Click **+ where** button.
12. From the **Choose parameter** dropdown list, select the **sku** parameter.
13. From the **Choose operator** dropdown list, select Boolean **Is true**.
14. Define the period from which the aggregate will collect products from the event to the last **30 days**. 
15. Save the aggregate.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/last-100-sku.png" class="full" alt="Configuration of the aggregate">
<figcaption>Configuration of the aggregate</figcaption>
</figure>

## Create an aggregate that collects the latest prices of products added by users to their favorites
---
This aggregate will return the prices of products from the previous aggregate. 


<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">

It is important to make sure that the conditions defined in both aggregates are the same in order to get the desired results when combining these 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 the name of the aggregate.
3. Click **Analyze profiles by** and select **Last multi** and size: **100**.
5. From the **Choose event** dropdown list, select the **product.addToFavorites** event.
6. As the event parameter, select **price**.
7. Click **+ where** button.
8. From the **Choose parameter** dropdown list, select the **price** parameter.
9. From the **Choose operator** dropdown list, select Boolean **Is true**.
10. Click **+ where** button.
11. From the **Choose parameter** dropdown list, select the **sku** parameter.
12. From the **Choose operator** dropdown list, select **Not in Array**.
13. From the **Choose value** dropdown list, select the aggregate you created [earlier](/use-cases/price-drop-alert#create-an-aggregate-that-collects-sku-of-recently-purchased-products).
14. Define the period from which the aggregate will collect products from the event to the last **30 days**. 
15. Save the aggregate.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/last-100-price.png" class="full" alt="Configuration of the aggregate">
<figcaption>Configuration of the aggregate</figcaption>
</figure>

## Create an aggregate that collects the last sku's of products received by users with a discounted price 
---
This aggregate later in the process will be used to exclude discounted products already sent to users when the next message is executed. 

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 the name of the aggregate.
3. Click **Analyze profiles by** and select **Last multi** and size: **100**.
5. From the **Choose event** dropdown list, select the **product.priceDrop** event.
6. As the event parameter, select **sku**.
7. Define the period from which the aggregate will collect products from the event to the last **30 days**. 
8. Save the aggregate.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/aggregate-prod-price-drop.png" class="full" alt="Configuration of the aggregate">
<figcaption>Configuration of the aggregate</figcaption>
</figure>

## Create a workflow
---
Create an automation that will check whether customers have all the necessary consents to receive email communications, as well as whether they have already bought a product they previously added to favorites. If customers meet all the requirements, they will receive an email with products added to favorites whose price has been reduced.  

1. Go to **Automation Hub > Workflows > New workflow**.
2. Enter the name of the workflow.

### Configure the trigger
---
In this part of the process, select the customer segment for which you will run this campaign. In our case, these are customers who have added products to favorites and agreed to receive email communication. 

1. Start the workflow with the **Audience** node. In the configuration of the node:  
    1. Set the **Run trigger** option to **repeatable**.
    2. Set the interval at which you want to run the automation.
    3. Select the time zone.
    4. Select the **New audience** tab.
    5. Click **Define conditions**. 
    6. From the choose filter dropdown list select the **product.addToFavorite** event. 
    7. Define the time period for the **last 30 days**. 
    8. From the **Choose filter** drop-down list, select the **newsletter_agreement** parameter.
    9. From the **Choose parameter** drop-down list, select the **Equal** operator and specify the condition as **enabled**.
    10. Confirm by clicking **Apply**.  

  <figure>
  <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/audience-priceDrop.png" class="large" alt="Configuration of the Profile Filter">
  <figcaption>Configuration of the Profile Filter</figcaption>
  </figure>  

### Configure the Generate Event node
---
1. Add the **Generate Event** node. In this step, check if the product added to favorites by the user has been discounted.  
    In the configuration of the node:
    1. Enter the **Event name**. In our case, we are using `product.priceDrop` event.
    2. In the **Body** section, use the following jinjava and modify it to your needs:  
    
   <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">

   Jinjava inserted in **Generate event** body must have all empty spaces deleted.

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

        
<pre><code class="language-jinja">{
  "sku": " 
  {% set last_sku=[] %}
  {% set last_price=[] %}
  {% set last_objects_array=[] %}
  {% set final_sku=[] %}
  {% set list=[] %}
  {% aggregate LAST-ITEM-ID %} {# aggregate collecting product sku #}
    {% for sku in aggregate_result|reverse %} {# saving sku from aggregate to last_sku variable #}
      {% do last_sku.append(sku) %}
    {% endfor %}
  {% endaggregate %}
  {% aggregate LAST-PRODUCT-PRICE %} {# aggregate collecting product prices #}
    {% for price in aggregate_result|reverse %} {# saving prices from the aggregate to the price variable #}
      {% do last_price.append(price) %}
    {% endfor %}
  {% endaggregate %}
  {% aggregate LAST-PRODUCT-PRICE-DROP-SKU %} {# aggregate containing previously shown items #}
    {% for listSku in aggregate_result %} {# preparation of a variable list with items to be excluded #} 
      {% do list.append(listSku) %}
    {% endfor %}
  {% endaggregate %}
    {% for sku in last_sku %} {# creating an object containing the product id and price #}
      {% set index=loop.index0 %}
      {% do last_objects_array.append({sku: sku, price: last_price[index], index: index}) %}
    {% endfor %}
  {% set last_objects_array_uniq=last_objects_array|unique(attr='sku') %} {# downloading sku from objects for comparison with the catalog #}
    {% for last in last_objects_array_uniq %}
      {% set key_name=last.sku %}
      {% catalogvar.CATALOG-WITH-ACTUAL-PRICE(key_name).ATTRIBUTE-ACTUAL-PRICE %} {# catalog from which we retrieve the price with the selected attribute #}
      {% set catalog_item=catalog_result|float %}
      {% if last.price|float &gt; catalog_item|float %} {# condition to check if there has been a price drop #}
        {% if last.sku in list|join(',') %} {# condition that adds a comma to items that are affected by the price drop and are not in the list variable #}
        {% else %}
          {% do final_sku.append(last.sku) %}
        {% endif %}
      {% endif %}
      {% endcatalogvar %}
    {% endfor %}
    {% for sku in final_sku %} {# listing the final sku in the sku parameter #}
      {{sku}}
      {% if loop.index != final_sku|length%},{% endif %}
    {% endfor %}
  {% if final_sku|length &lt; 1 %} {# condition to check if any product had a price drop #}
    {{kill}}
  {% endif %}"
}</code></pre>


  
<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">

If you would like to make a change to the condition that must be met in order for the event to be generated, you can do so in this line: 
<pre><code class="language-jinja">{% if last.price|float &gt; catalog_item|float %}</code></pre>
 
  Currently, this condition checks if the price varies, regardless of how big the change in value will be.

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


  The result of the automation is an event, which in the sku attribute contains the sku of the discounted products, listed after the comma. If the event is empty, it means that none of the products met the price drop condition.

  An example of a generated event:

  <figure>
  <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/product.priceDrop_sku.png" class="full" alt="An example of a generated product.priceDrop event">
  <figcaption>An example of a generated product.priceDrop event</figcaption>
  </figure>

### Configure the Event Filter node
---
1. Add the **Event Filter** node. In the configuration of the node:  
    1. Check event **for period of time**.
    2. Define the time range to **1 minute**.
    3. From the **Choose event** dropdown list, select the **product.priceDrop** event.
    4. As the event parameter, select **sku**.
    5. From the **Choose operator** dropdown list, select **Regular expression**.
    6. As the value, enter `.+`
    7. Confirm by clicking **Apply**. 
2. For the **not matched** path, select the **End** node. 
3. For the matched path, select the **Send Email** node. 

### Configure the Send Email node
1. In the email configuration, select the template you previously prepared for the price drop campaign.   
   In the template, you can retrieve data from an event that appears in the **Event Filter** node.   
   You can learn more about how to reuse event parameters [here](/docs/automation/event-params-reuse).  

    The following code is an example of how to do it:       
    
   <details class="accordion"><summary>Example jinjava code</summary><div class="accordion-content"><pre><code class="language-jinja">{% set sku_array = event.params.sku %} {% set sku_from_array = sku_array|split(',') %} &lt;ul&gt; {% for sku in sku_from_array %} &lt;li data-snr-ai-product-id="{% catalog.Snrs-produktu-ogTag(sku).product:retailer_part_no %}"&gt; &lt;a class="snrs-AI--item-link" href="{% catalog.Snrs-produktu-ogTag(sku).og:url %}" title="{% catalog.Snrs-produktu-ogTag(sku).og:title %}"&gt; &lt;img src="{% catalog.Snrs-produktu-ogTag(sku).og:image %}" class="products-slider__item-image snrAI-product-image snrAI-product-image-{% catalog.Snrs-produktu-ogTag(sku).og:image %}" width="90" alt="{% catalog.Snrs-produktu-ogTag(sku).og:title %}" id="snrAI-image-{% catalog.Snrs-produktu-ogTag(sku).product:retailer_part_no %}"&gt; &lt;h3 class="snrs-AI-product--product-name"&gt; &lt;span class="snrs-AI-product--name-first"&gt;{% catalog.Snrs-produktu-ogTag(sku).og:title %}&lt;/span&gt; &lt;/h3&gt; &lt;/a&gt; &lt;/li&gt; {% endfor %} &lt;/ul&gt;</code></pre></div></details>
  

   In addition, you can retrieve, for example, images or other parameters from your catalog.

2. Confirm by clicking **Apply**. 

### Add final setting to your workflow
---
1. Add the **End** node. 
2. Launch the workflow by clicking **Save&Run**.

  <figure>
  <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/product.priceDrop-workflow.png" class="full" alt="Configuration of the workflow">
  <figcaption>Configuration of the workflow</figcaption>
  </figure>

## Check the use case set up on the Synerise Demo workspace
---
You can check the configuration of each step directly in the Synerise Demo workspace:  

- [Aggregate that collects sku of recently purchased products](https://app.synerise.com/analytics/aggregates/cf726d37-39af-3a09-bc8b-36953f1a4411)

- [Aggregate that collects product sku's added by the users to their favorites](https://app.synerise.com/analytics/aggregates/9d8f2b6d-c9d8-39f5-90f2-c354fd387c28)

- [Aggregate that collects the latest prices of products added by users to their favorites](https://app.synerise.com/analytics/aggregates/28e5708e-b957-3b7d-ae3c-09eae2a3e29b)

- [Aggregate that counts sku's of products added to favorites by a user](https://app.synerise.com/analytics/aggregates/378c1190-f2fe-3947-b5f8-f131ee782397)

- [Workflow](https://app.synerise.com/automations/automation-diagram/580e7865-5649-4edf-a9a5-9aca214bdb5b)

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)
- [Automation Hub](/docs/automation)
- [Catalogs](/docs/assets/catalogs/introduction-to-catalogs)
- [Email campaigns](/docs/campaign/e-mail)
- [Product feed](/developers/product-feed)
- [Reusing event context from preceding nodes](/docs/automation/event-params-reuse)
- [Segmentation](/docs/analytics/segmentations)
