Recommending complementary products to recently bought

Published September 12, 2022

You can use AI to offer customers a personalized shopping experience by suggesting relevant, complementary products that they might like. You can send those recommendations, based on cross-sell algorithms that select complementary products based on those recently bought, in your email marketing campaigns.

This use case describes how to prepare an automated workflow that sends an email with cross-sell recommendations. This use case uses an aggregate and AI cross-sell recommendations inserts in targeted customer communication. The workflow is triggered with event, and sends an email after a specific time period.

Example of communication for recommending complementary products to recently bought



In this use case, you will go through the following steps:

  1. Create an aggregate.
  2. Prepare AI recommendations.
  3. Prepare an email template.
  4. Create a workflow.

Create an aggreagate

In this step, create an aggregate that returns the SKU of the product a customer bought in the last 30 days. You will later use it as an insert in an email.

  1. Go to Analytics icon Analytics > Aggregates > New aggregate.
  2. Enter the name of the aggregate.
  3. As the type of the aggregate, select Last.
  4. From the Choose event dropdown list, select the event.
  5. From the Choose parameter dropdown list, select $sku parameter.
  6. In the calendar in the right bottom of the page define the period from which the aggregate will return products from the event.
    1. In this case, in the Relative date range section, click Custom, type 30 and from the the dropdown list, select Days.
    2. Click Apply.
  7. In the right upper corner, click Save.
  8. Copy the aggregate ID from its URL to use in Jinjava later.
The view of the configuration of the aggregate with last bought productst
Configuration of the aggregate with last bought products
Tip: Cross-sell recommendations which you will add to the email template have to have the context of the product based on which the items in the recommendations can be selected. It is provided by the SKU retrieved from the event in the aggregate.

Prepare AI recommendations

In this part of the process, you will configure a cross-sell recommendation which will be later used in the email template.

  1. Go to Communication icon Communication > Recommendations > Add recommendation.
  2. Enter the name of the recommendation (it is only visible on the list of recommendation).
  3. In the Type & source section, click Define.
  4. From the Catalog dropdown list, select an item feed.
  5. In the Type section, choose the Cross-sell recommendation type.
  6. Confirm the settings by clicking Apply.
  7. In the Items section, click Define.
    1. Click Add slot.
    2. Define the minimum and maximum number of items that will be recommended to the user in each slot.
    3. Optionally, define Static filters and Elastic filters.
    4. Confirm by clicking Apply.
  8. Optionally, you can define the Boosting factors and settings in the Additional settings sections.
  9. In the right upper corner, click Save.
  10. Copy the recommendation ID from its URL to use in Jinjava later.

Prepare an email template

In this part of the process, you will create an email template with a Jinjava code that contains the IDs of the aggregate and the recommendation you created in the previous steps.

  1. Go to Communication icon Communication > Email > Templates.
    1. To create a new template, click Create new.
    2. To create a template out of an existing template, click From template.
  2. Select the template.
  3. Select the wizard:
    1. Drag&drop builder - Create email templates with ready-made components.
    2. Code editor - Create email templates in CSS and HTML.
  4. To add the dynamic part to the email template (last bought product and AI recommendations), you use Jinjava and add your own CSS. Below you can find an example Jijnava code.
Check the Jinjava code

    <!-- Opening the tag that retrieves the value from the aggregate prepared in step 1--> 
    {% aggregate 6b009acf-d86a-3ac6-b299-cb3c5d64c04f %} 
    <!-- Assign an aggregate value to skuValue --> 
    {% set skuValue = aggregate_result[0] %} 
    <!-- Referencing with the help of variable to the snrs-product-ogTag directory built by default from OG tags. The variable names depend on the name of the OG tags on your page --> 
    <div class="wrapper-card"> 
        <h2 style="text-align:center">Product Card</h2> 
        <div class="card"> 
            <img src="{% catalog.Snrs-produktu-ogTag(skuValue).og:image %}" alt="Product image" style="width:100%"> 
            <h1>{% catalog.Snrs-produktu-ogTag(skuValue).product:brand %}</h1> 
            <p class="price">$ {% catalog.Snrs-produktu-ogTag(skuValue).product:price:amount %}</p> 
            <p>{% catalog.Snrs-produktu-ogTag(skuValue).og:title %}</p> 
            <p><button>Add to Cart</button></p> 
    <!-- Adding the skuValue variable to the array for which we will retrieve cross-sell products --> 
    {% set itemContext = [] %} 
    {% do itemContext.append(skuValue) %} 
    <!-- Downloading the cross-sell campaign for the product in the table --> 
    {% recommendations3 campaignId=fpmFSFlTRUoS itemsIds=itemContext %} 
        <!-- Iterating loop through the received products --> 
        {% for item in recommended_products3 %} 
        <!-- Listing the attributes assigned to the product in the feed --> 
        <div class="wrapper-card" style="width:25%;float:left"> 
            <h2 style="text-align:center">Product Card</h2> 
            <div class="card"> 
                <img src="{{ item.imageLink }}" alt="Product image" style="width:100%"> 
                <h1>{{ item.brand }}</h1> 
                <p class="price">$ {{ item.priceValue }}</p> 
                <p>{{ item.title }}</p> 
                <p><button>Add to Cart</button></p> 
        {% endfor %} 
    {% endrecommendations3 %} 
    Closing of the tag that gets the value from the aggregate prepared in point 1 --> 
    {% endaggregate %}

Note: You will find more about email templates in this article.

Create a workflow

To start sending emails with the recommendation to customers prepare a workflow, which in basic configuration may look like the one below.

  1. Go to Automation icon Automation > Workflows > New workflow.
  2. Enter the name of the workflow.
  3. As the first node, add Profile Event. In the configuration of the node, select the event that triggers the workflow. In this use case, it’s a event.
  4. As the second node, add Delay. In the configuration of the node, set the period according to your business needs.
  5. As the next node, add the Send Email node.
  6. In the Send Email node configuration:
    1. In the Sender details, define the account from which the email will be sent.
    2. In the Content section: 3. Enter the subject of the email which will be visible in the customer’s inbox. 4. Select the email template created in the previous step.
    3. Optionally, you can add UTM and URL parameters.
  7. Confirm by clicking Apply.
  8. Add the End node to finish the workflow.
  9. Optionally, you can set up the capping for this workflow based on your business needs.
  10. Click Save & Run.
The view of the configuration of the workflow
Workflow configuration

Check the use case set up on the Synerise Demo workspace

You can check the configuration of use case in Synerise Demo workspace:

If you don’t have access to the Synerise Demo workspace, please leave your contact details in this form, and our representative will contact you shortly.

Read more


We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.



Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker