Moments SDK
The Moments JavaScript SDK provides functions to display experiences.
All functions can be accessed using the window.wyng_moments
object.
Load 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
Name | Type | Description |
---|---|---|
experience_id | string - required | ID of the experience campaign. |
selector | string - required | A DOMString containing one or more selectors to match. |
Example
window.wyng_moments.load('90d60242ac120003', "#my-dom-id")
Unload 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
Name | Type | Description |
---|---|---|
experience_id | string - required | ID of the experience campaign. |
Examples
- Remove a specific experience
- Remove all experiences
window.wyng_moments.unload('90d60242ac120003');
window.wyng_moments.unload();
Get a unique visitor ID
Returns a unique, long-lived, domain-scoped ID for the current user, which can be used to identify returning visitors.
The local user ID is stored in localStorage
and scoped to the domain of the web page calling the function, including any subdomains.
This is the same ID used by Wyng experiences and the Profiles SDK to identify returning visitors. This ID may be used with the Profiles SDK or API to look up profile attributes and segments for visitors to a web page.
Syntax
window.wyng_moments.getLocalUserId()
Example
window.wyng_moments.getLocalUserId();
// ↳'8c2f813cc4a696f02567783eb1066e93'