Reputation: 828
I have ngx-google-analytics built into my website and it works very well so far. Problem: I live in the EU and now I need a cookie consent banner that should be able to turn tracking with ngx-google-analytics on or off. Can you somehow load modules dynamically? Or is there another way to activate the plugin only after consent?
Upvotes: 0
Views: 1042
Reputation: 1429
The library is using APP_INITIALIZER
token, which loads at start up time, before anything else in your Angular application. You can check the source code here. Scroll down near the bottom, you will see it appends the google-tag-script into the DOM.
And here is where it uses gtag
to send data to the server
I don't know much about GTM, but as in your description, I can make an assumption that the solution should be either do not let the library load at all or to stop it from sending data to server.
window['ga-disable-UA-XXXXX-Y'] = true;
won't work.Conclusion: unfortunately, with this current library, you cannot achieve what you want.
Upvotes: 1