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

$gtm is undefined #32

Closed
ThePeach opened this issue May 5, 2020 · 8 comments
Closed

$gtm is undefined #32

ThePeach opened this issue May 5, 2020 · 8 comments

Comments

@ThePeach
Copy link

ThePeach commented May 5, 2020

I just moved from the previous google-tag-manager nuxt plugin to this one and stumbled on a significant problem:
In development mode I don't intend to use the gtm plugin, so I load it with a bogus ID (GTM-XXXXX). This is causing me a lot of problems in the moment I try to trigger custom events where the plugin breaks the whole application, with the error:

TypeError: "this.$gtm is undefined"

is there a solution to this that doesn't mean to fence all calls with a check if $gtm is defined?

[edit] this is not happening with the old module

@ThePeach ThePeach changed the title $gtm not defined $gtm is undefined May 5, 2020
@VaguelySerious
Copy link

Did you try using the built in option for disabling the plugin in development mode?

// nuxt.config.js
{
  buildModules: [
    '@nuxtjs/gtm',
  ],
  gtm: {
    id: 'GTM-XXXXXXX' // your actual id
    dev: false // << this here
  }
}

@Spice-Z
Copy link

Spice-Z commented May 7, 2020

I have same issue.
I tried disabling the plugin in development mode, it doesn't work.

@Spice-Z
Copy link

Spice-Z commented May 11, 2020

Sorry, I can use $gtm to set gtm.dev = true in according with @VaguelySerious 's advice.
Did you try setting this options, @ThePeach ?

@xrei
Copy link

xrei commented Jun 1, 2020

I have same issue with dev set to false

Cannot read property 'push' of undefined
logging this.$gtm prints undefined

@pi0 pi0 closed this as completed in ec85699 Jun 1, 2020
@pi0 pi0 reopened this Jun 1, 2020
@pi0
Copy link
Member

pi0 commented Jun 1, 2020

Hi @ThePeach @xrei . I pushed an update to v2.3.0 with new enabled option. Your feedback is more than welcome on this change.

@pi0 pi0 closed this as completed Jun 1, 2020
@proArtex
Copy link

@pi0 thank you so much for this! Console logs are also very useful.

@francoguilherme
Copy link

@pi0 Should I be setting enabled to true in production mode?

@marcell17002
Copy link

any update ?

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

No branches or pull requests

8 participants