Skip to content

JavaScript Library

The JavaScript library is built on top of the RESTful API and it is designed to make it easy to communicate with eSales from a site both when fetching results and when notifying events.

API key and credentials

To be able to access and use the eSales API the customer on-boarding Pre-requirements must be fulfilled.


The first step to use the JavaScript library is to include the script in each HTML page communicating with eSales in some way.

Check JavaScript library version

Always check the latest JavaScript library version.

    <script type="text/javascript" 

The JavaScript library exposes an esales object which is the base to all interactions with the eSales cluster in the HTML page. Once the script is included in the HTML page, the next step (and also a general recommendation) is to instantiate an esales object by using the case sensitive Web API identifier for a cluster provided by Apptus and the market eSales should use to fetch content and group notifications.

var esalesObj = window.apptus.esales("{cluster-id}", "{market}");

Once the esales object is instantiated a session key and a customer key token are automatically generated (if not already present) and stored in cookies.


A session starts with the first interaction of a visitor that results in a query or notification via the RESTful API. The visitor is automatically assigned a randomized session and customer key which is a UUID / GUID. A new customer key and token, generated by the Customer Key Authentication class, will be assigned to the visitor when the visitor signs in to the website.

A session ends when the visitor signs out and the end session notification is sent. The set cookies are cleared and a new randomized session customer key is generated.

The default level of personalisation for the JavaScript library is the Medium level of personalisation.

Detailed information