Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Tag Manager not loading when you specify a data layer in the config #127

Open
lionelrudaz opened this issue Feb 20, 2017 · 4 comments

Comments

@lionelrudaz
Copy link

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

@elmisi
Copy link

elmisi commented Jul 3, 2017

Hi,

I had the same problem, after a while I found is connected to this:

https://stackoverflow.com/questions/29243170/404-error-for-google-tag-manager

I hope this can help others.

@bugduino
Copy link

bugduino commented Aug 2, 2017

Same problem here, I published the container but the dataLayer options are not serialized. Without dataLayer options it works as expected

@GabKlein
Copy link

GabKlein commented Oct 6, 2017

Any update on this ?

@kellyselden
Copy link
Collaborator

No updates, someone experiencing the problem will need to submit a fix.

bugduino added a commit to bugduino/ember-metrics that referenced this issue Nov 27, 2017
According to the GTM dev guide (https://developers.google.com/tag-manager/devguide) the dataLayer should be
set as a global variable and Google will be in charge of retriving such
variable with their gtm.js iframe.

Fixes adopted-ember-addons#127
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants