Skip to content

Instantly share code, notes, and snippets.

View hyebahi-trustarc's full-sized avatar

hyebahi-trustarc

View GitHub Profile
@hyebahi-trustarc
hyebahi-trustarc / cmp-generic-event-listener.js
Last active August 30, 2024 20:49
CMP - Generic Event Listener
window.addEventListener("message", (event) => {
let eventDataJson = null;
// We only care about TrustArc Events at this point. And TrustArc's even it encoded in JSON
try {
eventDataJson = JSON.parse(event.data);
} catch {
// Some other event that is not JSON.
// TrustArc encodes the data as JSON
// console.log(event.data);