Skip to main content

Agent

The Agent provides functionality to trigger activations. All JavaScript functions can be accessed using the window.wyng_moments object.

Loading an Experience

Loads a Wyng Experience inside of the DOM Node defined by the selector argument.

Syntax

window.wyng_moments.load(experience_id, selector)

Parameters

NameTypeDescription
experience_idstring - requiredID of the experience campaign.
selectorstring - requiredA DOMString containing one or more selectors to match.

Example

window.wyng_moments.load('90d60242ac120003', "#my-dom-id")

Removing an experience

Removes a Wyng Experience's DOM Node from the current page. If no experience ID is provided it will delete all DOM Nodes found that contain a wyng-id data attribute. This function may be used before loading a Wyng Experience, to ensure there are no conflicts.

Syntax

window.wyng_moments.unload(experience_id)

Parameters

NameTypeDescription
experience_idstring - requiredID of the experience campaign.

Examples

window.wyng_moments.unload('90d60242ac120003');

Get a visitor's Unique ID

Returns a unique, long-lived, domain-scoped ID to identify returning anonymous visitors. The local user ID is stored in browser local storage and scoped to the domain of the web page calling the function, including any subdomains. The local user ID may be used with the Profiles API to look up a profile and segments for anonymous visitors to a web page.

Syntax

window.wyng_moments.getLocalUserId()

Example

window.wyng_moments.getLocalUserId();
// ↳'8c2f813cc4a696f02567783eb1066e93'