Skip to content

Instantly share code, notes, and snippets.

@elephantsneverforget
Last active December 11, 2023 18:06
Show Gist options
  • Save elephantsneverforget/3266614908a02123c73e62985b60c6fb to your computer and use it in GitHub Desktop.
Save elephantsneverforget/3266614908a02123c73e62985b60c6fb to your computer and use it in GitHub Desktop.
// Lucky Labs creates a Custom Event with additional data
var luckyEvent = new CustomEvent('luckyEvent',
{
detail:
{
message: 'store_finder_event',
email: "[email protected]",
location: "",
otherInfo: "",
product: {}
etc...
}
}
);
// Lucky Labs dispatches the event in the parent frame
document.dispatchEvent(luckyEvent);
// Elevar listens for event and processes
document.addEventListener('luckyEvent', function (e) {
console.log('Lucky Event fired!');
console.log('Event Data:', e.detail);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment