Weekly alert about top products added to favorites
Adding products to a favorites list is a great way for customers to keep track of items they’re interested in. It’s also a valuable marketing tool for businesses, as it can help promote items that are popular among customers.
There are a few ways you can use favorites lists to your advantage. First, you can send alerts to your marketing team with the list of items most often added to favorites. This is a great way to keep the team updated and help them make decisions about future promotions, price changes, or increasing the number of those products in stock. You can also use favorites lists to promote products. For example, you can create a list of the most popular items added to favorites and use this to promote special offers or discounts. This is a great way to boost sales and encourage customers to take advantage of your products. Finally, you can use favorites lists to improve your customer service. By keeping track of items added to favorites, you can quickly identify any trends or issues. This can help you resolve problems more quickly and improve your overall customer service.
An alert can be sent via any channel, for example as an email, SMS or to an external tool such as Microsoft Teams or Slack. Additionally, the number of product or the frequency of sending the alert is fully configurable. You may also include products added to the basket, frequency of product visits/products added to cart, and so on.
This particular use case shows how to send an alert with 20 products most often added to favorites last week. This alert is sent once a week in the form of an email.
Prerequisites
- Implement a custom event of adding products to favorites. Implement custom events in your mobile application or website,
In this use case, this event is named
product.addToFavorites
. - Create a segmentation of users who will be the recipients of this email alert. This segmentation will be used later in the workflow.
- Create a workspace API Key and assign the
ANALYTICS_BACKEND_REPORT_READ
permission which allows to retrieve a summary of all reports in the workspace.
Process
In this use case, you will go through the following steps:
- Create a metric which counts the number of products added to favorites during last 7 days.
- Create a report based on the metric created earlier.
- Create an email template with the Jinjava insert which injects the report results from the last 7 days.
- Create a workflow which sends the email alert every 7 days with the latest report results.
Create a metric
In this part of the process, create a metric that calculates the number of all products added to favorites in the last 7 days.
- Go to Analytics > Metrics > New metric.
- Enter the name of the metric.
- As a metric kind, select Simple metric.
- As the metric type, select Event.
- As the aggregator, set Count.
- As the occurrence type, set All.
- From the Choose event dropdown list, select
product.addToFavorites
. - To select a specific time range, click the calendar icon. In our case it will be last 7 days. Confirm your choice with the Apply button.
- Click Save.
Create a report
In this part of the process, create a report to clearly show the list of 20 products which were added most frequently to favorites in last 7 days.
-
Go to Analytics > Report > New report.
-
Enter the name of the report.
-
Select the metric you created in the previous part of the process.
-
From the Range dropdown list, select the number of top (the most frequently added to favorites) products to be shown in the preview of the report. In this case it will be TOP 20 products.
-
In the Dimension section, from the dropdown list select Events > Parameters. To be able to show products name in the report, choose name.
-
Click Add dimension.
-
From the list, choose sku.
Note: In this particular use case, we use two dimensions: name and SKU. This way, we will receive the SKU and name of the products in the report. You can use any number of dimensions based on your business needs. -
In the date range, select the time that will be analyzed. In this case it will be 7 days.
Important: Select the same date range as you selected for the metric and the segmentation (if you used there date range). -
Save the report.
-
Click preview to see the results.
Download the code of the report
To be able to use this report in the automation process, download the code using the developer console and save it in your notepad.
-
Go to Analytics > Reports and find the report created in the previous step.
-
Open the developer console in your browser: Click in the upper-right-hand corner (3 dots) of the browser window and select More Tools > Developer Tools.
-
Open the Network tab.
-
Open the preview of the report results.
-
In the console, in the filter box, paste
preview
. -
Click on the event which appeared on the list, choose the tab Payload and copy the code.
-
Copy this code to the notepad. You will use it in the next step.
Create an email template
In this part of the process, create an email template with a Jinjava code which inserts the current results from the report created in the previous part of the process.
-
Go to Communication > Email.
-
On the left pane, click Templates.
-
Select the wizard:
- Drag&drop builder - use ready-made components to build an email template.
- Code editor - use HTML, CSS and JS to build an email template from scratch.
-
Build a template.
-
Add the Jinjava code presented below. This code includes a context of the node from the workflow you will create in the next part of the process. Thanks to this context, the latest results of the report will be injected to the email template.
Check the Jinjava code{% set raportParams = automationPathSteps['waitReport'].event.params %} {% set final = [] %} {% for item in raportParams["body.data[0].values[0]"] %} {% do final.append({ "name":item.name[0], "sku": item.value, }) %} {% endfor %} {% for item in final %} {{final.name}} - {{final.sku}} <p> {%endfor%}
-
Save the template.
Create a workflow
In this part of the process, you will create the workflow which sends an email every 7 days with the current report results.
- Go to Automation > Workflows > New workflow.
- Enter the name of the workflow.
Add the Audience node
In this step you will create the audience who will get the report you have created.
- Click Add trigger.
- From the dropdown list, select Audience.
- Click the node.
- Set the Run trigger to repeatable.
- Define the frequency of launching the workflow (the Interval field) and when your workflow will be launched for the first time (the Begin at field).
- In the Define audience, select the segmentation you created as a part of prerequisites.
- Click Apply.
Add the Outgoing Integration node
This webhook will be used to calculate the results of the report created in the previous step. We use the method from API documentation.
-
Select the Custom webhook tab.
-
In the Webhook name field, enter
report.preview
. -
Select the POST method.
-
Enter the endpoint.
-
Leave the content-type at default (
application / json
). -
In the request body, paste the payload of the report you received in this part of the process.
Check the examplary JSON body of the report{"analysis": {"title": "[UC] Added to favorites", "description": "", "filter":{"matching": true, "expressions": [], "expression":{"name": "", "type": "EMPTY"}}, "reportMetrics": [{"metricId": "b665b739-55f8-4e5b-bc50-fa759142f8ef", "dateFilter":{"type": "RELATIVE", "duration":{"type": "DAYS", "value": 7}, "offset":{"type": "DAYS", "value": 0}}, "comparison":{"dateFilter":{"type": "ABSOLUTE"}}, "action":{"id": 93615, "name": ""}, "format":{"dataFormat": "numeric", "useSeparator": true, "compactNumbers": false, "fixedLength": 1}, "grouping":{"type": "TOP", "top": 20}, "groups": [{"title": "name", "type": "EVENT", "format":{"dataFormat": "numeric", "useSeparator": true, "compactNumbers": false, "fixedLength": 1}, "attribute":{"type": "PARAM", "param": "name"}},{"title": "product.addToFavorite sku", "type": "CLIENT", "format":{"dataFormat": "numeric", "useSeparator": true, "compactNumbers": false, "fixedLength": 1}, "attribute":{"type": "AGGREGATE", "id":"db965f80-1be4-3adb-9568-2282df80e9c8", "uuid":"db965f80-1be4-3adb-9568-2282df80e9c8"}}]}]}, "allowNull": true}
-
Select the method of authorization as by API key.
-
From the dropdown list, select the API key you created as a part of prerequisites.
-
Click Apply.
Define the Event Filter node
This node will let you get the report results from the last 7 days. Based on that, you will be able to add it to the email.
- As the next node, add Event Filter. In the configuration of the node:
- As the name of the node, enter
waitReport
. It is important to add it, as the Jinjava code in the email template contains a reference to the name of this node ({% set raportParams = automationPathSteps['waitReport'].event.params %}
). - Set the Check option to for period of time.
- Set the time range. In our case, it is 10 minutes.
- In the Define conditions section, from the Choose event dropdown menu, choose
webhook.response
event. - From Choose parameter dropdown menu, choose name.
- From the Choose operator dropdown, choose String, and then select Equal.
- In the next field, type the
report.preview
. - Click the + where button and from Choose parameter dropdown menu, choose status.
- From the Choose operator dropdown, choose Number, and then select Equal.
- In the next field, type the
200
.
- As the name of the node, enter
- Confirm by clicking Apply.
Configure the Send Email node
In this part of the process, the workflow sends an email which contains the report with 20 products most frequently added to favorites during last 7 days.
- For the Matched path, add the Send Email node.
- In the settings of the node:
- Define the settings of the Sender details section.
- In the Content section, enter the subject of the email and select the template you prepared in the previous part of the process.
- Optionally, define the settings in the UTM & URL parameters and Additional parameters sections.
- Click Apply.
Prepare the final settings
- After Send Email, add the End node as well as to the Not matched path.
- Optionally, define capping.
- Optionally, add titles to each node so the workflow will be more understandable to your colleagues.
- Activate the workflow by clicking Save & Run.
What’s next
Information from this report might be used in the following campaigns:
- Special promotions for products most frequently added to favorites
- Price regulations
Check the use case set up on the Synerise Demo workspace
You can check the metric, report and workflow configuration directly 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.