TLDR: I need to initialize google tag, meta pixel, zendesk chat, only after user has consented, and with localization via the url.
I had set up gtag in my <head> but now need to implement cookie consenting, I have now set up a script to append scripts to the head when a user clicks agree, but, the global function that I need to set up in order to report conversions is no longer accessible.
setup : SSG/hybrid (404), vanilla js, localization in the url.
Some issues:
- Global scoping a function so I can call it from a button click.
- Holding off on initializing zendesk chat until cookie preference is selected (UI conflict).
- Can't access window.localStorage in layout file.
Compromise: I could set the styling such that the cookie consent and the zendesk chat widget don't interfere, but it might look weird.
Is there a general pattern I can follow here?
🙏🏻