Skip to content

Instantly share code, notes, and snippets.

@LMG23
Last active January 24, 2023 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LMG23/271cb6005c9db8db66dd43a417a6257e to your computer and use it in GitHub Desktop.
Save LMG23/271cb6005c9db8db66dd43a417a6257e to your computer and use it in GitHub Desktop.
window.usabilla_live("setEventCallback", function(category, action, label, value) {
if(action != "Campaign:Open") {
return;
}
window.addEventListener("message", function(event) {
// Listen to messages from the Usabilla Cloudfront domain
if(!/d6tizftlrpuof\.cloudfront\.net/.test(event.origin)) {
return;
}
try {
var data = JSON.parse(event.data);
// On the final page
if(data.type === "pageSwitch" && data.end) {
for(var key in data.data) {
ga('gtag_trackerName' + '.send', 'event',
'GetFeedback Web Campaign - ' + label, // event category
key, // event action
data.data[key] // event label
);
}
}
} catch(e) {
// Ignore errors, usually JSON decode problems
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment