Initializing the JavaScript Library
Using the init method
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 this address.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
<script type="text/javascript">
xo.init({
activity: {
trackerKey: 'YOUR TRACKER KEY',
region: 'YOUR REGION'
}
});
</script>
Once you have initialized the library, you can move on to identifying the user by following the link below.
Using custom storage
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.
<script type="text/javascript">
xo.init({
activity: {
trackerKey: 'YOUR TRACKER KEY',
region: 'YOUR REGION',
storage: myCustomStorage
}
});
</script>
This parameter takes an object with the same methods as the localStorage
api (see localStorage documentation) so 4 methods:
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.
Last updated