Skip to content

Instantly share code, notes, and snippets.

@jpblancoder
Last active March 6, 2025 22:36
Show Gist options
  • Save jpblancoder/f2bedcd50c3230f4d30b492cb6561d29 to your computer and use it in GitHub Desktop.
Save jpblancoder/f2bedcd50c3230f4d30b492cb6561d29 to your computer and use it in GitHub Desktop.
function sendAmplitudeEvent({ event, data }) {
if (window.parent !== window) {
window.parent.postMessage({
type: "@fusion/ampliEvent",
payload: { event, data },
}, "*");
}
}
// Page view event - fire once on page load
sendAmplitudeEvent({
event: "contentImpressions",
data: {
"click feature": "election provincial map",
"click label": "something including the percentage of polls reported is probably good enough"
}
});
// User hyperlink click event
sendAmplitudeEvent({
event: "linkClick",
data: {
"click article id": undefined, // not an article page
"click feature": "election provincial map", // lowercased!
"click label": "specific to clicked text or unique label", // lowercased!
"click target url": "https://www.tgam.ca/foo/bar/page.html" // of anchor href
}
});
// User button click event
sendAmplitudeEvent({
event: "buttonClick",
data: {
"click article id": undefined, // not an article page
"click feature": "election provincial map", // lowercased!
"click label": "specific to clicked text or unique action name", // lowercased! e.g. `add-to-basket`
"click target url": undefined // not an anchor
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment