Recommending products using merge tags

Personalise your emails based on a previously purchased product. Product recommendation. Up-sell. Cross-sell.

Marek Szwed avatar
Written by Marek Szwed
Updated over a week ago

You can use Ecomail to further work with purchases and activity of your contacts to further personalise your email campaigns.

To further work with these functions, it is necessary to have a product feed set up in your account, along with having sent order info to your Ecomail account. Your product feed should contain products that match the products in the orders, especially the product ID. You can set up order transfer with one of our integrations or with API.

In this article you will learn how to:

Displaying last purchased products

The following merge tags can only be used within automation

If you wish to show a customer the last product they purchased in one of your campaigns, you can do this with the following merge tag:


The attributes you can work with are:

  • id

  • image_url

  • (product) url

  • name

  • description

  • price

You can display certain attributes by inserting the following merge tags into your template:

*|ECM_LAST_BOUGHT[1].productId|* - Product ID
*|ECM_LAST_BOUGHT[1].img_url|* - Image URL
*|ECM_LAST_BOUGHT[1].url|* - Product URL
*|ECM_LAST_BOUGHT[1].name|* - Product title
*|ECM_LAST_BOUGHT[1].price|* - Product price
*|ECM_LAST_BOUGHT[1].description|* - Product description

Only the last 5 products purchased can be displayed.

You can list the products based on the condition on how many last bought products are available in the history. Therefore the amount will be always valid and a situation where you would try to list three products when only two would be available will not happen.

Recommending products based on the purchased products

The following merge tags can only be used within automation

If you wish to further personalize your templates by recommending products for your customers based on the products they have already purchased, the following merge tag will allow you to do so:

These socks would look good with the shoes!

For example, if a customer purchases a pair of shoes (ID 1234567), we may offer socks as an add-on to these items in the email. We can personalize in general on multiple products or specifically by product attributes in each category (for example, offering matching materials, colours, etc.).

Note: 456 and 789 are the product IDs that you send in your orders. The merge tag content is always listed according to the product purchased by that contact. You can also insert content other than text in the editor.

Listing already purchased products

With the Merge tag, you can not only offer products but also inform your customers about what products they purchased with them:

You can then set up an automation that will target only the audience that has purchased a product from a category, or that has purchased a product that includes the name of the author.

Advanced options for working with the conditional merge tag bought product

The following merge tags can only be used within automation

Time values

For example, if you need to find out whether a customer has purchased a particular product in the last 14 days and recommend other suitable products to them accordingly, you can add the condition *|ECM_BOUGHT['product code']<=14|* to the merge tag. Using the condition, you can then use the examples above to set what you want to display to a specific user if they have purchased the products in the specified period.

*|IF:ECM_BOUGHT['product code']<=14|* Purchased something in the last 14 days *|END:IF|*

Bought in category

You can also make recommendations based on the category from which the customer purchased the product. The merge tag *|ECM_BOUGHT_CATEGORY['category name']|* is great for this.

You can then recommend a product related to that category as follows:

*|IF:ECM_BOUGHT_CATEGORY['category']|* Product related to the category. *|END:IF|*

How you work with the merge tag is up to you. For example, you can set a condition in the email template if the customer has purchased from the category in the past. If they meet the condition, you can show them a banner with their favourite brand, for example.

Bought anything

In some cases, you only need to check whether the customer has made a purchase. It doesn't depend on the specific product or category. In this case you can use a merge tag *|ECM_BOUGHT_ANYTHING|*.

Free shipping! Use code 12345.

Again, you can specify the condition with a time condition.

Here we check that the contact has made a purchase more than 90 days ago, i.e. has not purchased anything in the last 90 days:


This way you will only be able to show special promotions like free shipping to customers who have not purchased from you for a long time and you would like to reactivate them.

Random product from a product feed

If you want to recommend a random product in your campaign or automation, use the following merge tags:


123 is the product feed ID, which can be found in the product feeds section of your account

The [1] is the product index, if you want to list two products the merge tag in the template will be once with index [1] and secondly with index [2]



Could not send an email in automation

This situation might happen if you are trying to send a product that no longer exists in the e-shop (i.e. you are trying to remind a contact of a purchase for which the data no longer exists). The app will notify you of this error (both by email and in the app).

If this situation happens (e.g. due to frequent change of your e-shop assortment), we recommend to solve the situation by adding a condition with a merge tag to the part where you use merge tags for LAST BOUGHT -> this way the application will check if the purchase data exists for the contact and will only show the block to those for whom the data exists, and those for whom it doesn't will be sent an email without the "last purchased product" block.

For example:

Last time you bought:


How to set up an image

The image is inserted via the source code of the textual content (Source on the toolbar). We also recommend setting a maximum size for product images, as they will otherwise be displayed at their original size. The code for such an image may look like this:

<img alt="*|ECM_BASKET[1].name|*" src="*|ECM_BASKET[1].img_url|*" width="250" />

"250" is a maximum size of an image

Did this answer your question?