JavaScript library¶
The JavaScript library is built on top of the RESTful API and it is designed to make it easy to communicate with Elevate from a site, both when fetching results and when notifying events.
API key and credentials¶
To be able to access and use the Elevate 3 Enterprise API the customer onboarding Prerequirements must be fulfilled.
Set-up¶
The first step to use the JavaScript library is to include the script in each HTML page communicating with Elevate in some way.
Check JavaScript library version
Always check the latest JavaScript library version and make sure to use version 2.
Backwards compatibility
The JavaScript library for Web API v2 is not backwards compatible with Web API v1.
<head>
...
<script type="text/javascript"
src="https://cdn.esales.apptus.com/api/apptus-esales-api-2.X.Y.js">
</script>
...
</head>
The JavaScript library exposes an esalesAPI
object which is the base to all interactions with the Elevate 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 api
object by using the case sensitive Web API identifier for a cluster provided by Voyado and the market Elevate should use to fetch content and group notifications.
var api = window.esalesAPI({ market: '{market}', clusterId: '{cluster-id}' });
Once the api
object is instantiated a session key and a customer key are automatically generated (if not already present) and stored in cookies. The cookies, if present must be valid UUID v4 strings.
Default arguments
Some arguments will automatically be submitted via the JavaScript library when making panel queries and notifications, these are esales.market
, esales.customerKey
, and esales.sessionKey
.
Sessions¶
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 are both UUID v4 / GUID. A new customer key, a UUID supplied by the retailer website, 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.