Developer platform

JavaScript Web SDK

Overview

The Web SDK is a way to interact with the iAdvize solution from the client side.

Safely accessing the iAdvize object

If the iAdvize tag was installed using the recommended script (see https://ha.iadvize.com/admin/site/current/code), there should be a global window.iAdvizeInterface available. You can safely push functions inside window.iAdvizeInterface : they are guaranteed to be executed once the iAdvize tag is fully loaded.

window.iAdvizeInterface = window.iAdvizeInterface || [];
window.iAdvizeInterface.push(function(iAdvize) {
  // Ex : accessing the tag version
  const tagVersion = iAdvize.get('tag:version');
});

List of methods

MethodDescription
activateActivates the tag with an identity. Needed when authentication is enabled.
getGetters
on / offEvent listeners
helpDisplays a list of available commands in the console
logoutRemoves an identity, effectively stopping the tag when authentication is enabled.
navigateChanges the current screen and restart the tag, allowing a new targeting run
recordTransactionRecords a transaction
setSetters

iAdvize.activate / iAdvize.logout

These methods are used for authentication. Please see the dedicated Help Center article : https://help.iadvize.com/hc/articles/6043078724626

iAdvize.get

iAdvize.get takes a single property argument, and returns the associated value. Properties are keys that reference values that can change over time. These values can be accessed :

  • directly, using iAdvize.get (ex: iAdvize.get('visitor:cookiesConsent'))
  • when they change, using iAdvize.on (ex: iAdvize.on('visitor:cookiesConsentChange', callback))
PropertyDescriptionValues
tag:versionThe tag version"LIGHT", "FULL"
visitor:cookiesConsentWhether the visitor consented to cookies or nottrue, false, null (default)
visitor:GDPRConsentWhether the visitor consented to GDPR or nottrue, false, null (default)

Ex :

window.iAdvizeInterface = window.iAdvizeInterface || [];
window.iAdvizeInterface.push(function(iAdvize) {
  const visitorCookiesConsent = iAdvize.get('visitor:cookiesConsent');
});

iAdvize.on / iAdvize.off

iAdvize.on takes two arguments :

  • The name of an event,
  • A callback that takes the associated event value as parameter.

Every property available on iAdvize.get also has a corresponding event (iAdvize.on('{property}Change', (value) => {...})). iAdvize.off takes the same arguments to remove the event listener.

Ex :

window.iAdvizeInterface = window.iAdvizeInterface || [];
window.iAdvizeInterface.push(function(iAdvize) {
  iAdvize.on('visitor:cookiesConsentChange', function(visitorCookiesConsent) {

console.log(visitorCookiesConsent);

}); });

iAdvize.set

Set editable properties.

PropertyDescriptionValues
visitor:cookiesConsentWhether the visitor consented to cookies or nottrue, false
visitor:GDPRConsentWhether the visitor consented to GDPR or nottrue, false

Ex :

window.iAdvizeInterface = window.iAdvizeInterface || [];
window.iAdvizeInterface.push(function(iAdvize) {
  iAdvize.set('visitor:GDPRConsent', true);
});

iAdvize.help

  • Lists all the available methods,
  • Lists all the available properties on get and set,
  • Lists all the available events on on and off.

iAdvize.recordTransaction

Allows to record transactions. See the dedicated article on the Help Center : https://help.iadvize.com/hc/en-gb/articles/206375538

Ex :

window.iAdvizeInterface = window.iAdvizeInterface || [];
window.iAdvizeInterface.push(function(iAdvize) {
  iAdvize.recordTransaction({

id: 'unique-id',
amount: 49.95,

}); });