adopted-ember-addons / adopted-ember-addons/ember-metrics
Google Tag Manager not loading when you specify a data layer in the config
- Lenguaje dominante
- TypeScript
- Estrellas
- 367
- Forks
- 158
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Hi @poteto
First of all, thanks for your addon, it looks really awesome!
I'm trying to track my app using GTM. I'm only on the first steps of my implementation, and I just did this into environment.js
```
ENV.metricsAdapters = [
{
name: 'GoogleTagManager',
environments: ['development', 'production'],
config: {
id: 'GTM-NLXM2K',
dataLayer: [{
'pageCategory': 'signup',
'visitorType': 'high-value'
}]
}
}
];
```
And this in my router.js file
```
const Router = Ember.Router.extend({
location: config.locationType,
rootURL: config.rootURL,
metrics: Ember.inject.service(),
didTransition() {
this._super(...arguments);
this._trackPage();
},
_trackPage() {
Ember.run.scheduleOnce('afterRender', this, () => {
const page = this.get('url');
const title = this.getWithDefault('currentRouteName', 'unknown');
Ember.get(this, 'metrics').trackPage({ page, title });
});
}
});
```
Basically, nothing fancy, just your example from the Readme doc.
When doing so, I've got this error:
404: GET https://www.googletagmanager.com/gtm.js?id=GTM-NLXM2K&l=%5Bobject%20Object%5D
It's like it doesn't serialize the data layer.
Any clue how I can solve that? Also, I'm very keen to know how you can edit the datalayer on the fly depending on the route. Any example?
Thanks in advance
Guía de contribución
Línea de trabajo
Reproduce the issue using the environment.js metricsAdapters config and router.js tracking snippet from the report. Start by checking how the GoogleTagManager adapter turns the dataLayer config into the GTM script URL. Done means specifying a data layer no longer produces an l=%5Bobject%20Object%5D URL and the existing page tracking still works.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, typescript
- Área
- analytics, frontend
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 24/100