Wunderkind provides a Web SDK as a way to implement event tracking on a website.
The Wunderkind Web SDK loads with Smart-Tag and is attached to the window as part of the wunderkind window object.
We recommend using the following function to access the SDK to avoid any issues due to race conditions between when your site loads, events fire, and when Smart Tag loads with the Web SDK.
function wunderkindSDK(eventName, payload) {
var sdk = window.wunderkind &&
window.wunderkind.sdk &&
window.wunderkind.sdk.events;
if (sdk) {
if (sdk[eventName]) {
return sdk[eventName](payload);
}
// Optionally log the error
// console.log('wunderkindSDK Event method not found:', eventName);
return;
}
try {
var items = JSON.parse(localStorage.getItem('wknd_web_sdk_preloaded_events'));
} catch (e) {
// Optionally log the error
// console.log('wunderkindSDK Error parsing preloaded events:', e);
}
if (Object.prototype.toString.call(items) !== '[object Array]') {
items = [];
}
items.push({ eventName: eventName, payload: payload });
localStorage.setItem('wknd_web_sdk_preloaded_events', JSON.stringify(items));
}
Events
Logged In / Identified
When a visitor to a website is known or identified, a "logIn" event should be fired. This should be passed on every page view.
Place the following code on the website within a condition that is checking if a visitor is in a logged in / authenticated state.
Note: Only one of the properties email, emailHash or espemailid must be provided.
wunderkindSDK(
"logIn", {
"email": <VALUE -- Use plain text emails>,
"emailHash": <VALUE -- Use a SHA256 hash of the plain text email>,
"espemailid": <VALUE -- Use the ESP ID of the user. >
}
);
Comments
0 comments
Article is closed for comments.