
In-app messaging has become an essential tool for businesses as it provides a direct and personal communication channel with customers.

Price drops are a key aspect of business strategy to drive sales, increase customer engagement, and enhance brand loyalty. In an ever-competitive market, price drops can help companies stand out and create a unique value proposition for their customers. With the right strategy, price drops can produce significant results, leading to revenue growth and increased customer engagement. 

For customers, price drops represent an opportunity to save money on products that interest them. This, in turn, can increase customer loyalty and satisfaction and encourage repeat purchases.

The scenario described in this use case involves using an in-app message to notify customers of price drops on recently viewed products. The in-app message will be displayed right after the start of the mobile session only for customers for whom the product they were viewing has actually been reduced in price.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/in-app-price-drop1.png" alt="In-app price drop message example"  class="medium no-frame">
</figure> 

## Prerequisites 
---
- Implement the [required version](/docs/campaign/in-app-messages/introduction-to-inapp-messages#requirements) of [Synerise SDK in your mobile app](/developers/mobile-sdk).
- Implement the [transaction events](/developers/web/transactions-sdk) using [SDK](/developers/web/transactions-sdk) or [API](https://developers.synerise.com/DataManagement/DataManagement.html#operation/CreateATransaction).
- [Create an item catalog](/use-cases/import-product-feed-to-catalog) containing information on the actual price of products. 

## Process
---

In this use case, you will go through the following steps:
1. [Create an aggregate that returns the IDs of visited products](/use-cases/in-app-price-drop-last-seen-products#create-an-aggregate-that-returns-the-ids-of-last-visited-products)
2. [Create an aggregate that returns the prices of visited products](/use-cases/in-app-price-drop-last-seen-products#create-an-aggregate-that-returns-the-original-prices-of-last-visited-products)
3. [Create an aggregate that returns sku of recently purchased products](/use-cases/in-app-price-drop-last-seen-products#create-an-aggregate-that-returns-the-skus-of-recently-purchased-products)
4. [Create an in-app campaign](/use-cases/in-app-price-drop-last-seen-products#create-an-in-app-campaign)

## Create an aggregate that returns the IDs of last visited products
---

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** drop-down list, select the **page.visit** event.
6. As the event parameter, select **product:retailer_part_no**.
7. Click the **+ where** button.
8. From the **Choose parameter** drop-down list, select the **product:retailer_part_no** parameter.
9. From the **Choose operator** drop-down list, select **Is true (Boolean)**.
10. Set the period for which the aggregate will return IDs of the viewed products to the last **30 days**.
11. Save the aggregate.

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

## Create an aggregate that returns the original prices of last visited products
---

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** drop-down list, select the **page.visit** event.
6. As the event parameter, select **product:original_price:amount**.
7. Click the **+ where** button.
8. From the **Choose parameter** drop-down list, select the **product:original_price:amount** parameter.
9. From the **Choose operator** drop-down list, select **Is true (Boolean)**.
10. Set the period for which the aggregate will return the original prices of viewed products to the last **30 days**.
11. Save the aggregate.

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

## Create an aggregate that returns the skus of recently purchased products
---
This aggregate will be used to exclude products that the customer has already purchased.

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** drop-down list, select the **product.buy** event.
6. As the event parameter, select **$sku**.
7. Click the **+ where** button.
8. From the **Choose parameter** drop-down list, select the **$sku** parameter.
9. From the **Choose operator** drop-down list, select **Is true (Boolean)**.
10. Set the period for which the aggregate will return skus of the viewed products to the last **30 days**.
11. Save the aggregate.

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

## Create an in-app campaign
---

In this part of the process, you will create an in-app campaign triggered by the `session.start` event. We will use a predefined template for the price drop scenario, so there is no need to create a template from scratch.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/experience-hub-icon.svg" alt="Experience Hub menu icon" class="icon"> **Experience Hub > In-app messages > Create new**
2. Enter a meaningful name for the in-app campaign.

### Define the audience
--- 
1. In the **Audience** section, click **Define**.
2. Select the **Everyone** tab.
3. Click **Apply**.

### Define content
---
1. In the **Content** section, click **Define**.
2. Click **Create message** and from the list of template folders, select **Predefined templates**.
3. Select **Price alert** template.   
    **Result:** You are redirected to the code editor.

   <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 edit the template in two ways, by editing the code of the template ([add inserts](/docs/campaign/in-app-messages/creating-inapp-templates/creating-inapp-template#adding-a-snippet-to-the-template-code), [add variables](/docs/campaign/in-app-messages/creating-inapp-templates/creating-inapp-template#adding-a-variable)) and/or by filling out the form in the **Config** tab. In this use case, we will use the capabilities of the predefined **Config** tab.

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


#### Edit form in the Config tab
---
The form in the **Config** tab is already filled in with default values. You can keep them or change them to fit your business needs.  
The fields in **Config** are split into two types: ones for dynamic content (related to Jinja) and ones for in-app appearance. The dynamic content fields must match the values in the catalog and the names of the attributes returned by the recommendations. The appearance fields only affect the visual layer of the in-app message.

1. In the **Header text** text box, type the header you want to display in the in-app message.
2. From the **Aggregate with IDs of products the customer interacted with** drop-down list, select the aggregate you created in [this step](/use-cases/in-app-price-drop-last-seen-products#create-an-aggregate-that-returns-the-ids-of-last-visited-products). You can find it by typing its name or ID in the search box. 

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

   In this scenario, customers interact with the product by viewing it. This is just one example. You can create other aggregates to show different types of interaction with the product, such as adding it to the cart or favorites list, etc. This also applies to all related aggregates used in this use case.

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

3. From the **Aggregate with prices of products the customer interacted with** drop-down list, select the aggregate you created in [this step](/use-cases/in-app-price-drop-last-seen-products#create-an-aggregate-that-returns-the-original-prices-of-last-visited-products). You can find it by typing its name or ID in the search box. 
4. From the **Aggregate with IDs of products purchased** drop-down list, select the aggregate you created in [this step](/use-cases/in-app-price-drop-last-seen-products#create-an-aggregate-that-returns-the-skus-of-recently-purchased-products). This field corresponds to the code fragment in the template that excludes products displayed in the in-app message, so the products with the IDs returned by the selected aggregate won't be displayed.  
You can find it by typing its name or ID in the search box. 
5. In the **Name of the catalog with product information** field, change the default `Snrs-produktu-ogTag` value to the catalog name with product information you use. In our case, we use the same product catalog.
6. In the **Name of the column with sale price** field, change the default `g:sale_price` value to the name of the column with sale price in your catalog with product information. In our case the name of the column with sale price is `product:sale_price:amount`.

   <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 price defined in this field refers to a column in the catalog with the discount price of the product.

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

7. In the **Name of the column with product title** field, change the default `og:title` value to the name of the column with product title in your catalog with product information.
8. In the **Name of the column with product link** field, change the default `og:url` value to the name of the column with product link in your catalog with product information.
9. In the **Name of the column with image link** field, change the default `og:image` value to the name of the column with image link in your catalog with product information.
10. Define the **Name of the column with average rating** and **Name of the column with number of ratings** fields if you want to include this information in your in-app message.
11. In the **Name of the column with price** field, change the default `product:original_price:amount` value to the name of the column with price in your catalog with product information.

    <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 price defined in this field refers to the column in the catalog with the original price of the product - the price before any reductions.

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

12. In the **Button text** text box, type the text you want to display on the in-app button that adds the product to the cart.
13. Define the color in the following fields: **Wrapper background color**, **Button background color**, **Button text color**.
14. After you make changes to the template, you can check the preview.
    1. Click the **Preview** button on the upper left side.
    2. Enter the ID of a customer or a product.
    3. Click **Apply**.
15. If the template is ready, in the upper right corner, click **Save this template > Save as**.
16. On the pop-up:
    1. In the **Template name** field, enter the name of the template.
    2. From the **Template folder** drop-down list, select the folder where the template will be saved.
    3. Confirm by clicking **Apply**.
17. To continue the process of configuring the in-app campaign, click **Next**.
18. To save your content changes, click **Apply**. 

### Select events that trigger the in-app message display
---
In this part of the process, define the event that triggers the display of the in-app message. In our case, the trigger is the start of the session start.

1. In the **Trigger events** section, click **Define**.
2. Select **Add event** and from the drop-down list, choose the `session.start` event.
3. Click the **+ where** button and as the parameter, choose `mobile`.
4. As the logical operator, select **Exists**.
5. Click **Apply**.
<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/session.start-trigger-event.png" alt="The view of In-app trigger event configuration"  class="full">
<figcaption>In-app trigger event configuration</figcaption>
</figure> 

### Schedule the message and configure display settings
---
As the final part of the process, you need to set the schedule, display settings configuration, capping, priority of the message among other in-app messages.

1. In the **Schedule** section:
    1. Click **Define**.
    2. Choose **Run immediately** option.
    3. Click **Apply**.
2. In the **Display settings** section:
    1. Click **Define**.
    2. Define the **Delay display** as **5** and **Priority index** as **1**. 
    
       <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 mobile application can display one in-app message at a time. If the conditions allow the display of several in-apps at a time, the priority is a decisive factor for displaying the message. The messages with lower priority aren’t queued.

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

    3. Enable the **Frequency limit** toggle to manage the frequency of in-app message display in the application.  
    In our case, we want to display the message to the customer maximum once a day.
    4. You can additionally enable the **Capping limit** toggle to limit the amount of time the in-app message can be displayed to a customer in general. 
    5. Click **Apply**.
3. Optionally, you can define the UTM parameters in the **UTM & URL parameters** section. Otherwise, click **Skip step**.
4. Optionally, you can add the custom parameters in the **Additional parameters** section. Otherwise, click **Skip step**.
5. To start your campaign, click **Activate**.
<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/price-drop-settings.png" alt="In-app campaign configuration settings"  class="large">
<figcaption>In-app campaign configuration settings</figcaption>
</figure> 

## Check the use case set up on the Synerise Demo workspace
---
You can check the configuration of the campaign components directly in Synerise Demo workspace:
- [Aggregate that returns the IDs of visited products](https://app.synerise.com/analytics/aggregates/d6b649d5-e0c5-3c2a-b311-4eaf3530e82b),
- [Aggregate that returns the prices of visited products](https://app.synerise.com/analytics/aggregates/300949d8-f120-3714-adcc-14a6c8bb6119),
- [Aggregate that returns sku of recently purchased products](https://app.synerise.com/analytics/aggregates/46a9c55a-f894-3d83-b7a5-d193e0223de9),
- [In-app campaign](https://app.synerise.com/communications/in-app/6eaea5ba-88a7-4507-a904-e09a2a99e867)

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)
- [In-app messages](/docs/campaign/in-app-messages)
- [Using in-app template builder](/docs/campaign/in-app-messages/creating-inapp-templates/creating-inapp-template)
- [Mobile campaigns](/docs/campaign/Mobile)


