User identification & templating
Identify users across devices and use template variables in Kompassify content.
Tagging / identifying users
To tag the same user across multiple devices (e.g. to avoid showing the same product tour twice for the same user), use window.kommpassifyIdUser:
window.addEventListener('message', function (event) {
if (event.data.TYPE === "KOMPASSIFY_BOOT_LOADER_IS_READY") {
window.kommpassifyIdUser(userId);
}
});
Parameters
| Property | Type | Description |
|---|---|---|
| userId | String | An ID that is unique to each user. |
Using template variables in Kompassify
You can use template variables in Kompassify tools (checklist, progress bar, multi-choice, etc.). For example in your content:
Hello {{myUserName}} ! How are you?
Then set the variable via the API (after the boot loader is ready):
window.addEventListener('message', function (event) {
if (event.data.TYPE === "KOMPASSIFY_BOOT_LOADER_IS_READY") {
window.kompassifyTemplating.addTemplateVariable('myUserName', 'John');
}
});
The user will see: Hello John ! How are you?