
In today's fast-paced digital landscape, email marketing has evolved into a powerful tool for businesses to connect with their customers. The effectiveness of email campaigns often hinges on personalization. The ability to tailor content, products, and offers to individual recipients can significantly impact Key Performance Indicators (KPIs) and enhance the overall user experience. 

Email personalization goes beyond addressing the recipient by their first name; it's about delivering content that speaks directly to their interests, needs, and preferences. Such personalization can be done based on any attributes or activities of the customer, such as, for example, the customer's club status, transaction history, age in combination with any other variables, such as even the day of the month/week. The number of possible scenarios is huge, making it a great place to implement the most daring ideas.
<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/catalog-based-banner-main.png" alt="Email campaigns with catalog-based banners"  class="full no-frame">
</figure>

This use case describes a scenario in which customers receive email banners tailored to the following criteria:

- **Current Day of the Month:** Depending on the day, customers receive banners with special promotions relevant to that day.
- **Transaction History:** Customers are segmented into two groups based on whether they have made a transaction in the last 180 days or not.

**Assumptions:**
- The email is part of a specific marketing campaign scheduled for a particular month.
- All banner graphics and their links are stored in a catalog, with each day of the month having its own banner graphic for the respective audience.

**Scenarios:**  

Group 1: Customers with recent transactions  

For customers who have made at least one transaction in the last 180 days:
- **Days 1-15:** They receive Banner 1, offering a special promotion.
- **Days 16-31:** They receive Banner 2, featuring a different special promotion.

Group 2: Customers with no recent transactions  

For customers who have not made any transactions in the last 180 days:

- **Days 1-15:** They receive Banner 1, offering a specific discount for a particular product category.
- **Days 16-31:** They receive Banner 2, with a different discount for another product category.

## Prerequisites 
---
- Implement [Synerise tracking code](/developers/web/installation-and-configuration#creating-a-tracking-code) on your website.
- Permissions that allow access to Catalogs section and adding new catalogs.
- 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).
- Configure a [sender account](/docs/campaign/e-mail/configuring-email-account).
- Prepare a CSV file with banner graphics and corresponding links assigned to a specific day of the month and customer segment.    
The file used in this use case contains the following columns:
    - `DayOfTheMonth` - column that contains the days of the month (this column will be used as a catalog key)
    - `Group1banners` - column that contains banners dedicated to Group 1 (customers who have made at least one transaction in the last 180 days)
    - `Group2banners` - a column that contains banners dedicated to Group 2 (customers who have not made any transaction in the last 180 days)
    - `link1` - column that contains links to banners dedicated for Group 1
    - `link2` - column that contains links to banners dedicated to Group 2
    

      <details class="accordion"><summary>Example file</summary><div class="accordion-content"><figure> <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/file-with-banners.png" class="full" alt="Sample file"> <figcaption>Sample file</figcaption> </figure></div></details>


## Process
---
1. [Create a catalog](/use-cases/dynamic-email-campaign#create-a-catalog) with banners assigned to specific days of the week and customer segments. 
2. [Create an aggregate](/use-cases/dynamic-email-campaign#create-an-aggregate) showing whether a customer has made a transaction in the last 180 days.
3. [Create a jinjava](/use-cases/dynamic-email-campaign#create-a-jinjava-insert) insert to be used in the email template. 
4. [Create an email template](/use-cases/dynamic-email-campaign#create-an-email-template).

## Create a catalog
---
In this part of the process, create a catalog and import there your CSV file you prepared as a part of prerequisites. 

1. Go to **Data Modeling Hub > Catalogs > New Catalog**.
2. Enter the name of the catalog and confirm it by clicking **Apply**. 
    
   <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">

   Don't use diacritical letters and spaces.

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

3. Click the catalog on the list and click **Import Local File**.
    
If you prepared a CSV file in Excel, open it in a text editor to check whether commas are used as separators. If not, replace them with commas.
    
4. Click the **Upload a new file** button and select the file to be uploaded, then click **Next** button.
5. You will see the information that your file has been successfully uploaded. Click **Next** button to continue the import process.
6. In the **Primary key** field, type the name of the column whose values are treated as the key. In this case it will be `DayOfTheMonth`. Click **Next** button to continue the process.
    <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/catalog-primary-key.png" class="large" alt="Catalog primary key configuration">
    <figcaption>Catalog primary key configuration</figcaption>
    </figure>
7. In the next screen you will find the summary of your import. If no changes are needed click **Run import** button. 
    <figure>
    <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/import-success.png" class="large" alt="Import success">
    <figcaption>Import success</figcaption>
    </figure>

## Create an aggregate
---
Create an aggregate that show whether a customer has made a transaction in the last 180 days. The ID of this aggregate will be later used in the Jinjava code. 

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. Click **Analyze profiles by** and select **Exists**.
4. From the **Choose event** dropdown list, select the **transaction.charge** event.
5. Set the period from which the aggregate will analyze the results to the last **180 days**. 
6. Save the aggregate.

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

## Create a Jinjava insert
---
In this part of the process, prepare a Jinjava insert that will be used in the email template to display the relevant banner from the current day of the month to the appropriate customer segment.

Below you can find the jinjava insert used in this use case. 
There is the list of used values that you need to replace to tailor this Jinjava to your campaign:
- replace `insert_aggregate_ID` with the ID of your aggreagate 
- replace `insert_aggregate_name` with any unique aggregate name
- replace `insert_catalog_name ` with your catalog name
- in the `{{ catalog_result.link1 }}`, `{{ catalog_result.link2 }}` and `{{ catalog_result.Group1banners }}`, `{{ catalog_result.Group2banners }}` replace the `link1`, `link2` and `Group1banners`, `Group2banners` with the names of respective columns from the created catalog. 


  <details class="accordion"><summary>Check the Jinjava code</summary><div class="accordion-content"><pre><code class="language-jinja">&lt;!-- The purpose of the following part of Jinjava is to calculate the day of the month that corresponds to the current date plus 1 hour and save it as a string.).--&gt; {% set now = (unixtimestamp(null)|plus_time(1, 'hours'))|unixtimestamp() %} {% set now_sec = now|divide(1000) %} {% set current_date = (now_sec|int*1000)|datetimeformat('%d.%m.%y') %} {% set current_date_array = current_date|split('.') %} {% set today = current_date_array[0] %} {% set todayString = today|int|string %} &lt;!-- The logic behind the remaining part of Jinjava determines which set of HTML elements to generate based on the value of the aggregate result and the relevant links and image data from the catalog. This part divides customers into 2 groups based on their transaction activity (customers who have or have not made any transaction in the last 180 days).--&gt; {% aggregate insert_aggregate_ID %} {% set insert_aggregate_name = aggregate_result|last %} {%if insert_aggregate_name =='true' %} {% catalogitemv2.insert_catalog_name(todayString) %} &lt;a href="{% preparelink %}{{ catalog_result.link1 }}{% endpreparelink %}"&gt; &lt;img src="{{ catalog_result.Group1banners }}"&gt; &lt;/a&gt; {% endcatalogitemv2 %} {% else %} {% catalogitemv2.insert_catalog_name(todayString) %} &lt;a href="{% preparelink %}{{ catalog_result.link2 }}{% endpreparelink %}"&gt; &lt;img src="{{ catalog_result.Group2banners }}"&gt; &lt;/a&gt; {% endcatalogitemv2 %} {% endif %} {% endaggregate %}</code></pre></div></details>


## Create an email template
---
In this part of the process, create an email template. You can use a predefined template or create your own template from scratch. In this case, we will use the predefined template.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/experience-hub-icon.svg" alt="Image presents the Experience Hub icon" class="icon"> **Experience Hub > Email**.  
2. On the left pane, click **Templates** and from the list of template folders, select **Predefined simple templates**.
3. Select any template that mostly fits the campaign assumptions.  
**Result:** You are redirected to the code editor.
4. Edit the template according to your needs and add the row dedicated to the banner section.
5. Add **HTML** from the **Content** section to the created row and insert the Jinjava code you created in the previous step.
6. After you make changes to the template, you can check the preview. 
    1. Click the **Preview Contexts** button on the upper left side.
    2. Enter the ID of a customer.
    3. Click **Apply**.
7. If the template is ready, in the upper right corner, click the arrow next to **Next**, and from the dropdown select **Save as**.
8. On the pop-up:
    1. In the **Template name field**, enter the name of the template.
    2. From the **Template folder** dropdown list, select the folder where the template will be saved.
    3. Confirm by clicking **Save**.

Below you can find an example of email context preview.
<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/email-banner-example.png" class="medium" alt="Email context preview">
<figcaption>Email context preview</figcaption>
</figure>

## What's next
---
You can use this template in an email campaign by sending it manually or setting it up in Automation Hub as part of your business scenario.

## 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:  
- [Catalog](https://app.synerise.com/assets/catalogs/182804)
- [Aggregate](https://app.synerise.com/analytics/aggregates/860f507b-b2db-3b71-b98e-63a040183502)

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.

