Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

99
Vistas
Not able to push data to data layer on each page in angular 9

I am trying to add GTM snippet to my angular project. But on hard reload of page it's pushing data. On normal navigation it doesn't.

I have added GTM snippet provided by Google to index.html. what is the next step I need to do?

What I want is push dta to dataLayer on each page navigation or on Ngonit of each page?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

there are a lot of implemented angular modules which are wrapping interaction with GTM and provide some tools, for instance this one https://www.npmjs.com/package/angular-google-tag-manager here is how you can push event on each route change

class AppComponent implements OnInit {

    constructor(
       private router: Router,
       private gtmService: GoogleTagManagerService,
    ) { }

    ngOnInit() {
    
         this.router.events.subscribe(event=> {
             if (event instanceof NavigationEnd) {
                const gtmTag = {
                        event: 'page',
                        pageName: event.url
                      };
        
                this.gtmService.pushTag(gtmTag);
              }
         });
    }
}

also, you can move this logic to Guard (do not forget in such case to add it for routing)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda