setVar

NOTE
The setVar code is entirely separate from a data element specified in Tags.

Code

_satellite.setVar(name: string, value: *)

Example

_satellite.setVar('product', 'Circuit Pro');

setVar() sets a custom variable with a given name and value. The value of the variable can later be accessed using _satellite.getVar().

You may optionally set multiple variables at once by passing an object where the keys are variable names and the values are the respective variable values.

_satellite.setVar({ 'product': 'Circuit Pro', 'category': 'hobby' });

getVisitorId

Code

_satellite.getVisitorId() => Object

Example

var visitorIdInstance = _satellite.getVisitorId();

If the Adobe Experience Cloud ID extension is installed on the property, this method returns the Visitor ID instance. See the Experience Cloud ID Service documentation for more information.

logger

Code

_satellite.logger.log(message: string)
_satellite.logger.info(message: string)
_satellite.logger.warn(message: string)
_satellite.logger.error(message: string)

Example

_satellite.logger.error('No product ID found.');

The logger object allows for a message to be logged to the browser console. The message will only be displayed if tag debugging is enabled by the user (by calling _satellite.setDebug(true) or using an appropriate browser extension).

Logging Deprecation Warnings

_satellite.logger.deprecation(message: string)

Example

_satellite.logger.deprecation('This method is no longer supported, please use [new example] instead.');

This logs a warning to the browser console. The message is displayed whether or not tag debugging is enabled by the user.

_satellite.cookie contains functions for reading and writing cookies. It is an exposed copy of the third-party library js-cookie. For details on more advanced usage of this library, please review the js-cookie documentation.

To set a cookie, use _satellite.cookie.set().

Code

_satellite.cookie.set(name: string, value: string[, attributes: Object])
NOTE
In the old setCookie method of setting cookies, the third (optional) argument to this function call was an integer that indicated the cookie’s expiration time in days. In this new method, an “attributes” object is accepted as a third argument instead. In order to set an expiration for a cookie using the new method, you must provide an expires property in the attributes object and set it to the desired value. This is demonstrated in the example below.

Example

The following function call writes a cookie that expires in one week.

_satellite.cookie.set('product', 'Circuit Pro', { expires: 7 });

To retrieve a cookie, use _satellite.cookie.get().

Code

_satellite.cookie.get(name: string) => string

Example

The following function call reads a previously set cookie.

var product = _satellite.cookie.get('product');

To remove a cookie, use _satellite.cookie.remove().

Code

_satellite.cookie.remove(name: string)

Example

The following function call removes a previously set cookie.

_satellite.cookie.remove('product');