The Emarsys JavaScript API (also sometimes referred to as Web Extend) is a data collection system that captures the activity and behavior of website visitors. This information is used to enrich your Emarsys contact database with web behavior fields, and to generate personalized product recommendations for the Predict solutions.
Ready to jump in? Find our Javascipt API reference on the Emarsys Developer Hub.
How this works with other Emarsys products
The Emarsys JavaScript API may be used for both data collection and for obtaining Predict product recommendations. API features which are related to other Emarsys products (such as Predict) are marked as such in the Command Reference.
Prerequisites
In order to use the JavaScript API, you have to load the scarab-v2.js
JavaScript source to your page. The code snippet you need to insert into your websites HTML is available in your Emarsys Marketing Platform account. To display it, go to Management > Predict Data Sources and click Show tracking code in the Web Behavior box. The code you will see in the modal window already contains your Merchant ID, so all you need to do is paste it into your websites HTML.
Make sure to add our tracking code to all pages on your website, immediately before the </head>
element. As the scarab-v2.js
file is loaded asynchronously, it does not block the rendering of the page or the execution of other JavaScript code.
If you have already implemented the tracking code in your website, you can still display it at any time on the 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:
Capture explicit consent before collecting data
You must capture explicit consent before you start to collect data with Web Extend in that given web session.
Before you use Web Extend it is your responsibility to ensure that you always obtain the necessary consent for that data from your consumers (i.e: a natural person such as a customer, contact, or account). For more about Web Extend data collection, see the Emarsys Developer Hub.
Command Reference
You can find all information on implementing the Javascript API on your site on the Emarsys Developer Hub.
Web Extend supports the following commands: