This code makes it possible for you track the behavior of your visitors on your website using our JavaScript API commands, and it is also the basis of cross-device user identification and campaign tracking. Its implementation is a prerequisite for using those Emarsys products, such as Web Channel or Predict, that rely on the Web Extend data collection scripts.
The code snippet you need to insert into your website’s HTML is available in your Emarsys Marketing Platform account. To display it, go to Management > Predict Data Sources > Web Behavior and click Show tracking code. The code you will see already contains your Merchant ID, so all you need to do is paste it into your website’s HTML.
-
Make sure to add our tracking code to all pages on your website, immediately before the
</head>
element.
As thescarab-v2.js
file is loaded asynchronously, it does not block the rendering of the page or the execution of other JavaScript code. - Once the tracking code is in place, you have to add the go command as well to all pages on your website. This is responsible for sending all the JavaScript commands in the queue to the Web Extend service for processing and is required for the tracking code to work.
go
has to be issued on all the pages of your website only once, immediately before the</body>
element.
If you have already implemented the tracking code in your website, you can still display it at any time on the Predict Data Sources page. To do so, find the Account Details box on the bottom right-hand side, and click Tracking code next to your Merchant ID.
The cookie policy of Chrome from version 80 (2020.02.04.) onwards requires cookies to contain the SameSite
header. Additionally, the context of the cookie must be specified with an attribute. Emarsys complies with the new privacy policy requirements, therefore, after the browser update, customers do not need to change their cookie settings unless they are hosting their own version of the scarab-v2.js
file in the tracking code.
In this case, it is the responsibility of the customers to comply with the Chrome requirements by updating their own .js
script.
This ensures that Web Extend and Predict capabilities are unchanged with respect to user privacy.
Using the Emarsys hosted scarab-v2.js
file provides backward compatibility with older Chrome versions and other browsers.
For more information on the required cookie headers and attributes, see:
Check if it works
To see if the tracking code works properly on your website, do the following:
- In your browser, open a page on your website.
- Open another tab in your browser, log in to your Emarsys account, go to Management > Predict Data Sources > Web Behavior and click Live Events in the upper right-hand corner. This will open the Live Events page.
- Select my visit in the second drop-down.
- You should see an event box containing a cookie ID, a UTC timestamp and the referring URL.