codediodeio / angular-gtag

:bookmark: Google Analytics gtag.js for Angular
108 stars 20 forks source link

trackingId removed when run production mode. #3

Open insanehong opened 6 years ago

insanehong commented 6 years ago

Hi,

I have problem that trackingId removed when run production mode.

application info

set Import

# environment.prod.ts

{
  .
  .
   GA_ID : process.env.GA_ID,
  .
  .
}
# app.module.ts
GtagModule.forRoot({ trackingId: environment.GA_ID, trackPageviews: true})

development mode

// in app.comonent.ts
console.log(Gtag) 
> Gtag {router: Router, mergedConfig: {…}}
mergedConfig: {
 trackPageview: true, trackingId: "UA-122xxx040-2"

production mode

// in app.comonent.ts
console.log(Gtag) 
> Gtag {router: Router, mergedConfig: {…}}
mergedConfig: {
 trackPageview: true, trackingId: null
jonjaques commented 5 years ago

Same here, though it doesn't seem to matter if it's in the environment files or not in NG7

handylearn commented 4 years ago

We have a project which uses webpack and have the same problem: mergedConfig shows null for the trackingId in production. we use angular 8.2.x and gtag 1.0.4