Skip to content

Instantly share code, notes, and snippets.

@rubentd
Created January 21, 2020 17:52
Show Gist options
  • Save rubentd/0f8af377d83380f0a6fd4907ed799372 to your computer and use it in GitHub Desktop.
Save rubentd/0f8af377d83380f0a6fd4907ed799372 to your computer and use it in GitHub Desktop.
// This snippet is run when the React app has completed rendering the first page
// wait for OneTrust to be initialized
await waitForOneTrust();
try {
window.OneTrust.LoadBanner();
} catch(err) {
console.log('Error loading banner', err);
}
initGTM();
gtmEvent();
// Then this snippet is run when there's a changein the url
history.listen(() => {
// Trigger analytics events
gtmEvent();
});
@rubentd
Copy link
Author

rubentd commented Jan 21, 2020

you'll find the code for each function in: https://gist.github.com/rubentd/c9dc9fe0e223fb42bbd13ee25ef32c1e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment