Skip to main content
Personalisation by displaying the last viewed products

Automation of "browse without purchase", last visited product, personalization by merge tag LAST VIEW.

Kateřina Irová avatar
Written by Kateřina Irová
Updated over 2 years ago

Merge tag *|ECM_LAST_VIEW|* can only be used in an Automation.

A very useful feature to help you get the most out of your emailing and increase the likelihood of purchase is the display of specific products that your contact at

e-shop was last viewed.

Article content:


Setting the last view event

In order to use the merge tag and display the latest products, you need to have a product XML feed loaded in Ecomail. It is the products from the feed that are matched with the products in the browse event so that the products can be displayed in the email.

You can send the last viewed products to Ecomail in two ways:

a) Via JS tracking code (dynamically add product ID):

window.ecotrack('trackStructEvent', 'ECM_PRODUCT_VIEW', 'product_id');

b) Via API endpoint:

{
"event": {
"email": "email",
"category": "ECM_PRODUCT_VIEW",
"action": "product_id"
}
}

Creating personalised template

If you wish to show contacts specific products they have viewed, you need to prepare a dynamic template using merge tags. Products can be viewed in more ways.

Merge tags to display product properties

*|ECM_LAST_VIEW[1].img_url|* - URL of the image
*|ECM_LAST_VIEW[1].url|* - Product URL
*|ECM_LAST_VIEW[1].name|* - Product name
*|ECM_LAST_VIEW[1].price|* - Product price
*|ECM_LAST_VIEW[1].description|* - Product description

In the email template, you can display a maximum of 3 last viewed products.

💡 An image is inserted via the source code of the text content "< >". We also recommend setting a maximum size for product images. The code for such an image may look like this:

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

The newsletter has a width of 600px, so it is a good idea to set the image size accordingly.

Display options

Products stacked below

*|IF:ECM_LAST_VIEW[1]|*
Parameters[1]
*|END:IF|*

*|IF:ECM_LAST_VIEW[2]|*
Parameters[2]
*|END:IF|*

*|IF:ECM_LAST_VIEW[3]|*
Parameters[3]
*|END:IF|*

In the template this will be the output:

In order to display all products in the email correctly, each individual product needs to have its own condition, terminated by a relevant merge tag *|END:IF|* (as you can see in the picture above).

So if, for example, the second product in the sequence no longer exists on the e-shop, we will not display it and will automatically display the third product.

Different variations of product views

This condition will display the products according to how many the user has actually viewed (up to a maximum of 3 products), and the appearance of the template can also be adjusted accordingly [i.e. the products will not have to be sorted only under each other]).

  • if the user has viewed 1 product, only 1 product will be displayed in the template

  • if the user has viewed 2 products, 2 products will be displayed in the template

  • if the user has viewed 3 products, 3 products will be displayed (maximum number)

You can, for example, display 1 product in the middle, but in the case of 2 products display the products side by side.

*|IF:#ECM_LAST_VIEW=1|*
Parameters[1]

*|ELSEIF:#ECM_LAST_VIEW=2|*
Parameters[1]
Parameters[2]

*|ELSE:|*
Parameters[1]
Parameters[2]
Parameters[3]

*|END:IF|*

The output structure then looks like this:


Template vs. block with viewed products

You have two options to use the last viewed products in your email.

  • Sending a template containing only the last viewed products

    • This type of email will not be sent out if a contact doesn't have any last viewed products

  • Sending last viewed products as a personalised block in your automations

    • This type will be sent to all contacts, if a contact doesn't have last viewed products a block of last viewed products will not be displayed

A template that contains only the last viewed products

Is typically part of Abandoned Browsing automation, see next section and is not sent to contacts at all unless they have a history of viewed products.

In case you send the customer the last viewed products as a primary message without additional information, it is desirable that the newsletter is not sent at all in case of the absence of products (e.g. when they are deleted from the e-shop).

If the email would be sent out, it would be empty. You can make it so that the campaign will not be sent out by editing the primary condition:

A template that contains content along with a block with last viewed products

If you use an entry with the main condition before the last viewed products themselves, you can use such a block in an email template in any automation.

In case the contact does not have any last viewed products, the block is simply skipped.

Use the main condition before merge tags for the last viewed products:

*|IF:#ECM_LAST_VIEW=1|*

*|IF:#ECM_LAST_VIEW=1|*
Parameters[1]

*|ELSEIF:#ECM_LAST_VIEW=2|*
Parameters[1]
Parameters[2]

*|ELSE:|*
Parameters[1]
Parameters[2]
Parameters[3]

*|END:IF|*

*|END:IF|*

The template can then look like this:


Creating automation that responds to product viewing (Abandoned Viewing Automation)

Once the browsing event is tracked and the personalized template is ready, you can get started on creating an automated campaign.

Set the trigger frequency as desired, typically to "multiple times", and select the automation trigger for the custom event. Fill in the "custom event" with the exact values as shown below, i.e. ECM_PRODUCT_VIEW in the Category field.

This will trigger the automation the moment the contact views any product on the e-store.

The scenario of your automation can look like this:

  • Wait 48 hours (i.e. two days after viewing)

  • condition (check) that the user has not made a purchase in the last x days

  • if so (i.e. they have not purchased), send an email with custom content and the last products viewed

  • stop the automation

The automation can then look like this in Ecomail:

For this type of automaton, we recommend using a merge tag without the main condition (so that the email is not sent to contacts if, for example, the products viewed on the website no longer exist - see this part).

Testing

If you wish to test the process, you must first track your contact. You can do this easily in two ways:

  • Via the browser console (e.g. in Google Chrome via Developers tools or F12 > console), run the snippet and replace it with your email:

Once the track occurs, view the specific products. Then add your address to the contact list in Ecomail for which the automation is set up.

Wait for custom events to be written in the contact details and then insert the contact into the automation for testing.

Did this answer your question?