Skip to content

Instantly share code, notes, and snippets.

@jpblancoder
Last active March 6, 2025 22:36
Show Gist options
  • Select an option

  • Save jpblancoder/f2bedcd50c3230f4d30b492cb6561d29 to your computer and use it in GitHub Desktop.

Select an option

Save jpblancoder/f2bedcd50c3230f4d30b492cb6561d29 to your computer and use it in GitHub Desktop.

Revisions

  1. jpblancoder revised this gist Mar 6, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion iframe-ampli-events.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    function sendAmplitudeEvent({ event, data })
    function sendAmplitudeEvent({ event, data }) {
    if (window.parent !== window) {
    window.parent.postMessage({
    type: "@fusion/ampliEvent",
  2. jpblancoder revised this gist Mar 6, 2025. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions iframe-ampli-events.js
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ sendAmplitudeEvent({
    event: "contentImpressions",
    data: {
    "click feature": "election provincial map",
    "click label": "specific to clicked text or unique label"
    "click label": "something including the percentage of polls reported is probably good enough"
    }
    });

    @@ -22,7 +22,7 @@ sendAmplitudeEvent({
    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! e.g.
    "click label": "specific to clicked text or unique label", // lowercased!
    "click target url": "https://www.tgam.ca/foo/bar/page.html" // of anchor href
    }
    });
    @@ -32,7 +32,7 @@ sendAmplitudeEvent({
    event: "buttonClick",
    data: {
    "click article id": undefined, // not an article page
    "click feature": "election provincial map", // lowercased! e.g. "region name here"
    "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
    }
  3. jpblancoder created this gist Mar 6, 2025.
    39 changes: 39 additions & 0 deletions iframe-ampli-events.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    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": "specific to clicked text or unique label"
    }
    });

    // 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! e.g.
    "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! e.g. "region name here"
    "click label": "specific to clicked text or unique action name", // lowercased! e.g. `add-to-basket`
    "click target url": undefined // not an anchor
    }
    });