
Reuse the collected data about your customers in order to send personalized communication and help your customers find the best products for them. For this purpose you can use the size of a customer (you can collect it through transactions events) and send a message to the customers with the link to the discounted products in their size.

 
## Example of use - Retail industry 

A client from the retail industry decided to increase the personalization of their communication. Using aggregates, we can find the size of the individual customer’s last purchased product to prepare a special offer. When the customer made a purchase, the size he was interested will be collected in to the system, and in subsequent mailings would receive a personalized messages with a link to the products of the selected size. 

 - Email communication contained the size of the customer's shoes in the subject of the message: Check before they disappear! Shoes in size 39.
 - The email contained a link to a listing with the sizes adjusted to size of every individual customer.

Other customers who have not made any transaction so far, received a general email with the promotion and all available sizes, and they could specify which they are interested in. 

In this way, **2 groups of customers** received an email with the same promotion, but with a completely different message. 

<figure>
<img src="/api/docs/image/9d53dfb838a88616bc8bb794b1a854785f714c4a/use-cases/all-cases/_gfx/email-promotion-size.png" alt="Screenshot presenting email with promotion" class="full no-frame">
<figcaption> Email with a promotion based on a customer's size </figcaption>
</figure>

**Results** 

- **21,64%** open rate for the emails with the personalized size in the title. 
- **12,94%** open rate for the emails without the personalized size. 

The customer had 10% more transactions from emails in which he indicated a specific customer size. 

## Prerequisites 
---

To be able to implement this use case, you must:
- Add [tracking code](/docs/settings/tool/tracking_codes) to your website.
- Implement [transaction events](/developers/web/transactions-sdk) where you send size of bought products. 
- [Create an email account](/docs/campaign/e-mail/creating-email-campaigns).
- [Integrate forms](/developers/web/tracking-form-data).
 

## Process
---
To prepare an email with a promotion for the products in the customers' size, perform the following steps:

1. [Prepare an aggregate](/use-cases/email_with_a_promotion_for_products_in_the_customers_size#prepare-an-aggregate).
2. [Configure email communication](/use-cases/email_with_a_promotion_for_products_in_the_customers_size#configure-email-communication).
 

## Prepare an aggregate
---
Prepare the aggregate with the size of the last bought product.

1. To do it, create new [aggregate](https://app.synerise.com/spa/modules/analytics/aggregates/new). 
1. Go to <img src="/api/docs/image/9d53dfb838a88616bc8bb794b1a854785f714c4a/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 **Last**.
3. Select **product.buy** event, and specify the **size parameter.** 


<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 name of the size parameter can be different for every Synerise user - check the name of the size parameter you use in the transaction events.

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

<figure>
  <img src="/api/docs/image/9d53dfb838a88616bc8bb794b1a854785f714c4a/use-cases/all-cases/_gfx/email_with_a_promotion_customers_size_2.png" alt="Screenshot presenting aggregate conditions" class="full">
  <figcaption> Aggregate conditions </figcaption>
  </figure>


<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 Synerise every **transaction.charge** event generates additionally **product.buy** event, which store information about particular product which was bought – that's why in this use case we can use size parameter from such event.

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

## Configure email communication 
---

For this scenario, you have to configure an email message which will use the aggregate you prepared in the previous step. To configure the email communication you have to define the audience, create the content and set up the final settings.

### Define Audience of email communication

Selecting the right audience is a necessary step of preparing an email.  

1. Prepare such segment in [segmentation](https://app.synerise.com/spa/modules/analytics/segmentations/new) or create new segment directly in the **email message**.
2. Choose users who will get email.  


<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 use case our client wanted to send email to every user, who has ever made a transaction so such segment should contain of transaction.charge event which occured in lifetime period.

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

<figure>
 <img src="/api/docs/image/9d53dfb838a88616bc8bb794b1a854785f714c4a/use-cases/all-cases/_gfx/email_with_a_promotion_customers_size_3.png" alt="Screenshot with define audience mode" class="full">
 <figcaption> Define audience </figcaption>
 </figure>

### Create content 

After you selected the audience, create the content of your email message. 


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

In this example, you can create email for 2 groups of customers. One for customers who have made the transaction, and second for customers who have not made the transaction with the promotion and available sizes. We will provide you with the first scenario and the second you can made by using [email](/docs/campaign/e-mail/creating-email-campaigns) instruction.

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

1. At the beginning, select the email account from which the email will be sent.  
2.  In the **Email subject** field the enter the aggregate. For example: 
  
   <pre><code class="language-jinja">{% aggregate a1872106808667667%} Check before they disappear! Shoes in size {{aggregate_result [0] | float | round (0)}} {% endaggregate%}</code></pre>
 
   As a result, customer will see: **Check before they disappear! Shoes in size [size number of the customer]**. 
3. To create the content of the email, click **Create message**. In the email template include the Jinajava code that contains the link to the listing of products in the customers' size:


<details class="accordion"><summary>Check the Jinjava code</summary><div class="accordion-content"><pre><code class="language-jinja">&lt;!-- Opening the tag that retrieves the value from the aggregate prepared in point 1--&gt; {% aggregate xxx %} &lt;!--Creating link to website with params to filter to client's size, link below is only an example --&gt; {% set link = "your_link_to_listing.com/listing?size="+aggregate_result[0] %} &lt;!--Adding Synerise tracking parameters --&gt; &lt;a href="{% preparelink %}{{link}}{% endpreparelink%}"&gt; &lt;!-- Adding yours banner link --&gt; &lt;img src="your_image.jpg" /&gt; &lt;/a&gt; &lt;!--Closing of the tag that gets the value from the aggregate prepared in point 1 --&gt; {% endaggregate %}</code></pre></div></details>
 

<figure>
  <img src="/api/docs/image/9d53dfb838a88616bc8bb794b1a854785f714c4a/use-cases/all-cases/_gfx/email_with_a_promotion_customers_size_4.png" alt="Screenshot present creating aggregate" class="full">
  <figcaption> Create aggregate </figcaption>
  </figure>


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

To find the aggregate ID to replace XXX in the code, simply navigate to the aggregate in the Synerise application. The ID is the part of the URL that comes after /aggregates/, for example: **bfba46b4-e0d6-3ea9-8ae6-c7a2495c54c7** in the URL `https://app.synerise.com/analytics-v2/aggregates/bfba46b4-e0d6-3ea9-8ae6-c7a2495c54c7`. Copy this ID and use it in your code where needed.

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


### Prepare the final settings  
 
1. Add the title of the email.
2. In the **Schedule tab**, decide when your email is sent.
3. In the UTM & URL parameters section, add the parameters to track the email performance.
4. Send tests of your message to verify if the content of the email is displayed correctly.

<figure>
  <img src="/api/docs/image/9d53dfb838a88616bc8bb794b1a854785f714c4a/use-cases/all-cases/_gfx/email_with_a_promotion_customers_size_5.png" alt="Screenshot with final setings" class="full">
  <figcaption> Set up settings page </figcaption>
  </figure>


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

Test message can only be sent when the email has a title.

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

## Generated events

This use case generates approximately 3 events per profile that completes the flow:
[`message.send`](/docs/assets/events/event-reference/email#messagesend) (~1), [`newsletter.open`](/docs/assets/events/event-reference/email#newsletteropen) (~1), [`newsletter.click`](/docs/assets/events/event-reference/email#newsletterclick) (~1).

## Read more 
---
- [Aggregates](/docs/crm/aggregates)
- [Email communication](/docs/campaign/e-mail/creating-email-campaigns)
- [Jinjava](/developers/inserts/exptest)
- [Segmentation](/docs/analytics/segmentations/introduction-to-segmentations)
