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 Admin > 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.
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 Admin > 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.
