User Identification
getLocalUserId
Across Wyng platforms an anonymous visitor ID is be assigned to each
visitor, that is used to identify returning visitors. The ID is scoped by the
fully qualified domain of the containing web page, and stored in browser
localStorage
on the visitor's device, as value uid
.
Different browsers have different expiration times for data stored in browser localStorage
.
For example Safari will store the data in browser localStorage
for a maximum of 7 days of inactivity on the domain, while
Chrome will not expire the data in browser localStorage
unless the user clears their data.
Example
Get the anonymous visitor ID for the current visitor. If no ID has been set,
a random value will be generated and stored in browser localStorage
.
window.wyng['_WYNG_ID_'].getLocalUserId()
isAuthenticated
Checks if the user is authenticated for the current experience.
A user is considered authenticated if they have recently verified their identity while interacting with a form of the experience.
See the Identity Verification help article.
Parameters
email
(optional): The email address of the user to check authentication for. If not provided, checks if any email address has been authenticated on the user's machine for the experience.
Response
A Promise that resolves to a boolean indicating whether the user is authenticated.
Example
const isAuthenticated = await window.wyng['_WYNG_ID_'].isAuthenticated('example@wyng.com');
console.log(isAuthenticated); // true or false