nuxt-community / legacy-modules

MIT License
1.29k stars 157 forks source link

Google Tag Manager needs Jquery #330

Closed nachogarcia closed 4 years ago

nachogarcia commented 4 years ago

Version

latest

Steps to reproduce

Install the module, add the ID and start the app.

What is expected ?

The module works properly

What is actually happening?

It breaks because it needs Jquery

VM9248:1 Uncaught ReferenceError: jQuery is not defined
    at sender (<anonymous>:1:37)
    at <anonymous>:1:316
    at gtm.js?id=GTM-******&l=dataLayer:4683
    at c (gtm.js?id=GTM-******&l=dataLayer:4685)
    at Ab (gtm.js?id=GTM-******&l=dataLayer:4487)
    at e (gtm.js?id=GTM-******&l=dataLayer:4531)
    at gtm.js?id=GTM-******&l=dataLayer:4476
    at Array.<anonymous> (gtm.js?id=GTM-******&l=dataLayer:4532)
    at Object.bg (gtm.js?id=GTM-******&l=dataLayer:4531)
    at Oe (gtm.js?id=GTM-******&l=dataLayer:4532)

Looks like GTM needs jQuery to work. Maybe we should put it as a peer dependency.

Additional comments?

I'm also using https://github.com/nuxt-community/analytics-module and it works flawlessly.

This bug report is available on Nuxt community (#c175)
nachogarcia commented 4 years ago

I think GTM does not need jQuery, it's just that they also included a jQuery license because part of their code is very similar to it. Looks like my client is injecting some code in the tag that needs jQuery and that is the cause of the issue. Will look into it, and if the problem continues I would reopen the issue.

federicovezzoli commented 4 years ago

I have the same issue: https://blabstudiostighidi.netlify.com/

Don't have jquery installed and not planning to do it. Any help?

thanks!