Initializing the JavaScript Library
Using the init method
Last updated
Using the init method
Last updated
The init
function is available under the xo
, xo.activity
and xo.search
namespace.
Example :
xo.init({activity: {activityOptions}, search: {searchOptions}})
xo.activity.init({activityOptions})
xo.search.init({searchOptions})
The activityOptions
parameters are:
trackerKey
: your unique trackerKey to enable the tracking functions.
region
: the region in which your data is stored: currently only EU is available, and that's the region enabled by default.
storage
: optional, used to define custom storage.
The searchOptions
parameters are:
token
: your unique Search token, available in your Console at .
region
: the region in which your data is stored. Available regions are listed below, and the default is EU.
Europe (default)
EU
United States
US
Once you have initialized the library, you can move on to identifying the user by following the link below.
When the library is initialized, a default storage is defined. (localStorage for the browser version, or as a variable for the nodeJs version).
To use custom storage you may use the storage
option as described below.
setItem(key, value)
The value
to be stored and its key
getItem(key)
Return the value
for given key
from storage
removeItem(key)
Remove key and value from storage
clear()
Clear storage
All key
, and value
must be String.
This parameter takes an object with the same methods as the localStorage
api (see ) so 4 methods: