Created
January 21, 2020 17:52
-
-
Save rubentd/0f8af377d83380f0a6fd4907ed799372 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you'll find the code for each function in: https://gist.github.com/rubentd/c9dc9fe0e223fb42bbd13ee25ef32c1e