Email with the products most frequently visited by a customer
It is worth remembering how important it is to analyze what users view on the website, what subpages they visit and how much time they spend there. Behavioral data is the basis for creating a specific marketing strategy and appropriate personalization.
Remember that even if the users do not add anything to the basket, they can be reminded of the products they most often visited by sending them a personalized email.
Example of use - Electronic industry
A client from the electronics industry decided to make use of information about the products customers viewed. However, instead of sending them the products they viewed recently, they were sent most viewed products in general.
If the customers were on the site but did not add anything to the cart, after the session ended, they would receive an email with the products they visited more than once - ordered from the most to the least frequently visited.
Prerequisites
To implement this use case, you have to:
- Implement tracking code on your website.
- Implement OG Tags.
- Import product feed.
- Create product catalog.
- Integrate transaction events.
- Have add to cart event.
- Create and set up your email account.
- Import your subscriber’s database to Synerise.
Process
To create an email with products most frequently visited, perform the steps in the following order:
Prepare the aggregate
- Go to Analytics > Aggregates > Create aggregate.
- As the aggregate type, select Profile.
- Click Analyze profiles by and select Last Multi and size:100.
- Choose event page.visit with product:retailer_part_no parameter.
- Save your aggregate.
Prepare the workflow
-
Go to Automation > Workflows > New workflow.
-
Add an Profile Event as a trigger node.
-
Select the session.end event.
-
Click Delay to define the duration of delay - after the session ends, the system waits for the time defined in the Delay node before the email is sent.
Note: Remember that event session.end appears 30 minutes after the last user activity on the website. -
Add the Generate Event node. It generates an event on the customer’s profile. In this case, the event will contain ID of the most frequently viewed products by a customer.
- In the Event name, enter the name, for example
topvisited.products
. - In the Label field, enter the label that will be shown in the customer’s profile, for example,
Top visited products
. - In the Body, enter the Jinjava code available below. Replace AGGREGATE_HASH with the hash of the aggregate you in the previous step. As a result you will analyze the products that the user has viewed, sort them in order of the most frequently viewed to the least viewed (products that have been viewed at least two times) and return them to the userโs card in this event.
Note: An event created in this way will return all the products that the user saw at least twice within the time specified in your aggregate. The event with parameter will be returned in the form of the sku listed after the decimal point, e.g.: top: sku1, sku2, sku3.CHECK JINJA CODE{ "top": "{% set skus = [] %} {% set counter = [] %} {% set skusTmp = [] %} {% set skuDict = [] %} {% set sortDict = [] %} {% aggregate AGGREGATE_HASH %} {% for sku in aggregate_result|unique %}{% set k = [] %}{% for tmp in aggregate_result %}{% if sku == tmp %}{% do k.append('+') %}{% endif %}{% endfor %}{% do skuDict.append({'sku':sku,'counter':k|length }) %}{% endfor %}{% endaggregate %}{% for dictItem in skuDict %}{% do counter.append(dictItem.counter)%}{% endfor %}{% set sortCounter = counter|sort() %}{% for count in sortCounter %}{% for dictItem in skuDict %}{% if dictItem.counter == count && dictItem.sku in skusTmp == false %}{% do skusTmp.append(dictItem.sku) %}{% do sortDict.append(dictItem) %}{% endif %}{% endfor %}{% endfor %}{% set top = [] %}{% set len = sortDict|length + 1 %} {% for i in range(len) %}{% set ind = sortDict|length - i %}{% set item = sortDict[ind] %}{% if sortDict[ind].counter > 1 %}{% do top.append(sortDict[ind].sku) %}{% endif %}{% endfor %}{{ top|join(',')|trim }}" }
- In the Event name, enter the name, for example
-
Add Profile Event Filter. This node allows you to wait for the event sent in the previous node. When the event appears on the customer’s profile, it will be possible to refer to its parameters in the next node - here in send.email, you will refer to the “Top” parameter via
{{event.params.top}}
-
Add the Send Email node. In the message template, we can use {{event.params.top}} which will return the “top” parameter of the last event we sent. For example, sku1, sku2, sku3 which can then be converted into an array using the | split (’,’) function and use in the template structure.
{% set topProducts = event.params.top %} {% set skus = topProducts|split(',') %}
-
Save your workflow.
Results:
It will result in an array:
skus = [sku1, sku2, sku3] which we can then use to build a template - we can, for example, download items from the product catalog and simply display them in our email or download similiar recommendations for the most viewed item (skus [0])
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: