You can track user behaviour on your website, record their activity, actions with products, orders, etc. Based on the data obtained, segment the base by customer or user activity, which will allow you to conduct marketing campaigns much more effectively.
With connected tracking you have access to such functions as:
In the following articles you can read about the practical application and monetization of tracking in mailings and learn about:
• how an online store increased email channel revenue 13 times in 4 months
• how an online storefront converted every sixth abandoned browse into a purchase
There are two ways to install tracking - script or API. You can choose the one that is easier for your team to install and fits your technical capabilities.
Installation instructions for each option are described below.
To calculate revenue using tracking, be sure to specify the site where tracking will be set up in “Account Settings” in enKod
All methods for tracking user actions are available in our API documentation in the "Tracking" section.
Please note that the methods will only work if the Tracking module is enabled for your account. If you want to use this functionality - contact your personal manager or at [email protected].
Features of using the API:
When setting up tracking by API, we cannot automatically detect if a contact is in the database (similar to the script and eksubsemail parameter). But you can set up the same logic yourself:
Please note that when setting up tracking by API, the segment conditions for pop-ups based on basket and page visits will not work. To use these conditions, you need to pass basket change events using the JS script method.
The script will be loaded only once when the website is loaded for the first time, it does not affect the speed of switching between pages. All methods are called in the browser cache in the background and are invisible to the user.
Place the script on the site before the closing tag </body>.
<script type="text/javascript"> var script = document.createElement('script'); script.type = 'text/javascript'; script.src = '//cdn.enkod.ru/script/enpop.min.js'; script.async = true; var first = document.getElementsByTagName('script')[0]; first.parentNode.insertBefore(script, first); var enKodBox = window.enKodBox = window.enKodBox || {}; var ekEvents = window.ekEvents || []; enKodBox['token'] = 'system_name_of_the_account'; </script>
The system name of the account is set when creating an account in the platform and is not equal to the sending domain or website address. You can get the system name from your account manager.
Calling the script will look like this:
<script type="text/javascript"> ekEvents.push('action_name', { param1: 'and', param2: 'object', param3: 'with parameters' }) </script>
The first argument is the name of the action, and the second argument is a hashmap with parameters.
The list of events that can be tracked is described below.
<script type="text/javascript"> ekEvents.push('productOpen', { productId: 'product vendor code', groupId: 'product group identifier', param: 'value' }); </script>
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
productId | String | Product ID | Mandatory |
After the mandatory parameter you can specify, separated by commas, any product parameters that you want to pass to the service. For example, product category, group, etc.
<script type="text/javascript"> ekEvents.push('categoryOpen', { categoryId: 'category identifier', categoryUrl: 'URL of the category page' }); </script>
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
categoryId | Int | Product category identifier | Mandatory |
categoryUrl | String | Link to the category page on the website | Optional |
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
productId | String | ProductId | Mandatory |
count | Int | Item count. Default value is 1. You can assign any value to | Optional |
This method can be used in several ways. Let's look at them with examples:
<script type="text/javascript"> ekEvents.push('productAdd', { productId: 'product vendor code'}); </script>
<script type="text/javascript"> ekEvents.push('productAdd', { productId: 'product vendor code', category: '1', group: 'some-group', param: 'value'}); </script>
<script type="text/javascript"> ekEvents.push('productAdd', { productId: 'product vendor code', count: 2}); </script>
<script type="text/javascript"> ekEvents.push('productAdd', [{ productId: 'product vendor code', count: 2}, { productId: 'another vendor code', count: 5}]); </script>
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
productId | String | ProductID | Required |
count | Int | Quantity of product. Default value is 1. Can be set to any value | Optional |
This method can be used in several ways. Let's look at them with examples:
<script type="text/javascript"> ekEvents.push('productRemove', { productId: 'product vendor code'}); </script>
<script type="text/javascript"> ekEvents.push('productRemove', { productId: 'product vendor code', count: 2}); </script>
<script type="text/javascript"> ekEvents.push('productRemove', [{ productId: 'product vendor code', count: 2}, { productId: 'another vendor code', count: 5}]); </script>
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
productId | String | ProductId | Mandatory |
This method can be used in several ways. Let's look at them with examples:
<script type="text/javascript"> ekEvents.push('productLike', { productId: 'product vendor code'}); </script>
<script type="text/javascript"> ekEvents.push('productLike', { productId: 'product vendor code', category: '1', group: 'some-group', param: 'value'}); </script>
<script type="text/javascript"> ekEvents.push('productLike', [{ productId: 'product vendor code'}, { productId: 'another vendor code'}]); </script>
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
productId | String | ProductId | Mandatory |
This method can be used in several ways. Let's look at them with examples:
<script type="text/javascript"> ekEvents.push('productDislike', { productId: 'product vendor code'}); </script>
<script type="text/javascript"> ekEvents.push('productDislike', [{ productId: 'product vendor code'}, { productId: 'another vendor code'}]); </script>
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
productId | String | ProductId | Mandatory |
<script type="text/javascript"> ekEvents.push('productComparison', {product: {productId: 'product vendor code'}}); </script>
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
productId | String | ProductId | Mandatory |
<script type="text/javascript"> ekEvents.push('productComparisonRemove', {product: {productId: 'product vendor code'}}); </script>
<script type="text/javascript"> ekEvents.push('productComparisonClean'); </script>
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
orderId | String | Order ID. If not passed, it is generated automatically | Mandatory |
items | [{}] | Array of products | Mandatory |
sum | Float/Int | Order amount | Mandatory for outputting revenue in the interface |
productId | String | Product ID | Mandatory for recommendation module |
price | Float/Int | Product price | Mandatory for recommendation module |
count | Int | Quantity of each product in the order | Mandatory for the recommendations module |
<script type="text/javascript"> ekEvents.push('productBuy',{orderId: 'id', sum: 1000, items: [{productId: 'product vendor code 1', count: 5, price: 10}, {productId: 'product vendor code 2', count: 1, price: 50}]}) </script>
<script type="text/javascript"> ekEvents.push('productBuy',{orderId: 'id', items: [{productId: 'product vendor code', count: 5}], finalPrice: '100', param: 'value'}) </script>
If you want to collect contact information at checkout and record the order itself in enKod, then use a sequential call to the subscribe and checkout methods:
<script type="text/javascript"> async function subAndOrder() { await ekEvents.push('subscribe', { integrations: [1], groups: [1, "sysname"], fields: { email: '[email protected]', lastName: '', phone: '70000000000' } }) await ekEvents.push('productBuy', { orderId: '84781', items: [{ productId: '5y347p92', size: '92', count: 1, price: 230 }], sum: 230 }) } subAndOrder() </script>
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
orderId | String | ID of the order that needs to be returned | Mandatory |
<script type="text/javascript"> ekEvents.push('orderReturn',{orderId: 'id'}) </script>
When processing a return, the revenue parameters will be recalculated, the number of orders and purchased products will not change.
You do not need to connect the tracking module to use this method
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
groups | Int/String [] | Array of mailing group ids and/or system names of mailing groups to be assigned to the subscriber when added to the platform | Optional |
fields | Object | List of basic fields | Optional |
extraFields | Object | List of extra fields | Optional |
mainChannel | String | The main channel is either 'email' or 'phone'. It is passed only if 2 channels are passed at once in subscribe method | Optional |
cartMergeMethod | String | • merge - The contents of the existing contact's basket will be merged with the contents of the basket of the contact sent in the request; • ignore - The contents of the basket of the contact sent in the request will be ignored, the contents of the existing contact's basket will be saved | Optional |
favouriteMergeMethod | String | • merge - The content of the existing contact's favorites will be merged with the content of the favorites of the contact sent in the request; • ignore - The content of the favorites of the contact sent in the request will be ignored the contents of the existing contact's favorites will be saved | Optional |
Contacts are added and updated according to the addAndUpdate method:
Field parameters: subscriber information
Name | Type | Description | Mandatory |
---|---|---|---|
String | User email | Mandatory | |
firstName | String | Subscriber name | Optional |
lastName | String | Subscriber's last name | Optional |
phone | String | Subscriber's phone number | Optional |
<script type="text/javascript"> ekEvents.push('subscribe',{groups: [18, "group_name"], fields: {email: '[email protected]', firstName: 'name', lastName: 'surname', phone: '7900000000'}, extraFields: {systemName: 'value', systemName2: 'value'}}) </script>
In order for tracking to determine the email address of a contact who has reached the site from an email message, for all links in the message you must specify the URL parameter eksubsemail, in the value of which you must pass the recipient's email using the personalisation tag {{subscriber_email}}.
If you use fields of the list type in extraFileds
, please note:
Used to transfer data about a subscriber without binding to his/her email address. For example: recording the subscriber's city, phone number, age, etc. before the subscriber registers or logs in.
Reserved field names
Name | Type | Description | Mandatory |
---|---|---|---|
extraFields | Object | List of extra fields | Mandatory |
ekEvents.push('addExtraFields',{extraFields: {city: 'London', systemName: 'value'}})
If you use fields of the list type in extraFileds
, please note:
Method used to segment contacts based on their browsing history on the site. Should be installed on every page of the site. Together with the ekEvents.push('subscribe') method, it allows you to track visits to a page by specific users and segment them based on this data.
ekEvents.push('pageOpen')
ekEvents.push('event', {email:'[email protected]', phone:'79000000000', params: {param1: 'value1'}});
Where:
A contact's email and/or phone number can be passed with the method (not necessarily). If email and/or phone number are not passed or contacts with such identifiers are not found in your account, we will bind the event to a session if we know it. If the event is linked to a session and there is no session (and there is no email or phone number transmitted in your account), the event will not be displayed in enKod.
To use our script and methods in case you are using Google Tag Manager, you need to follow these steps:
1. To install the script you need to create a separate tag in GTM.
You can read more about tags in GTM at Google Help
To place a script inside a tag in GTM, you need to create a tag with “Custom HTML” type and “Once per event” tag triggering option (by default). Place the script code in the tag body, specifying the system name corresponding to your account (not equal to the site domain or account name, you can check with your account manager).
The appropriate trigger to start the tag should be based on the first load of any of the site pages or page view (the trigger is selected according to the conditions you need).
Read more about triggers in Google Help
2. To use tracking methods, you need to create a tag with the “Custom HTML” type for each method. In the body of the tag for the parameter values you need to specify the variables you use on your site.
For example, let's consider a method template for adding an item to cart and a working method in GTM with filled in client variables.
<script type="text/javascript"> ekEvents.push('productAdd', { productId: 'product vendor code', variant: 'product type', category: 'product category', count: 'product quantity'}); </script>
For each tag, you must set the trigger at which this method should be triggered and the exceptions (if necessary).
3. After tags are created, they should be saved and published.
Open the site, go to developer tools (F12 or Fn+F12).
Open the required DevTools section according to the screenshot.
Open any product, perform any target action for which tracking methods have been set (opening a card, adding to cart, ordering, adding to favourites, etc.).
Check that all enKod methods work correctly and without errors - return the status “200 OK”.