ngx-google-analytics
ngx-google-analytics copied to clipboard
load traking-code dynamically from server and set
how can i set traking-code dynamic in NgxGoogleAnalyticsModule.forRoot('traking-code')
enviroment.ts => ga = "YOUR-TRACKING-CODE"
NgxGoogleAnalyticsModule.forRoot(enviroment.ga);
Unfortunately this is not loading it dynamically from the server. Once compiled I believe your environment.ts file is part of the deployed package.
Look this article from Daniel Kreider (@dkreider) to observe directly use of gtag.
https://itnext.io/angular-google-analytics-the-complete-guide-6518736096a0
I thing you may use like
this.$gaService.set('config', 'YOUR-TRACKING-CODE');
But I don´t tested.
P.S.: I really sad with Google Analytics technology. I use Brave Browser and it blocks all external resources scripts, then ga shot fail and do not exists an API endpoint to make a http request. For my sites, I am using Matomo into a subdomain.