ngx-google-analytics icon indicating copy to clipboard operation
ngx-google-analytics copied to clipboard

load traking-code dynamically from server and set

Open kaffash999 opened this issue 2 years ago • 3 comments

how can i set traking-code dynamic in NgxGoogleAnalyticsModule.forRoot('traking-code')

kaffash999 avatar Mar 07 '22 08:03 kaffash999

enviroment.ts => ga = "YOUR-TRACKING-CODE"

NgxGoogleAnalyticsModule.forRoot(enviroment.ga);

avmesquita avatar Jun 27 '22 13:06 avmesquita

Unfortunately this is not loading it dynamically from the server. Once compiled I believe your environment.ts file is part of the deployed package.

Maleki avatar Jul 11 '22 10:07 Maleki

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.

avmesquita avatar Jul 11 '22 15:07 avmesquita