mib200 / vue-gtm

Simple implementation of Google Tag Manager in Vue.js 2.0
Apache License 2.0
242 stars 85 forks source link

"TypeError: Cannot read property 'defer' of undefined" after enabling the plugin with a user interaction #84

Closed peXed closed 4 years ago

peXed commented 4 years ago

Hello!

If you have the plugin disabled by default and then enable it after a user interaction (confirming the tracking) with this.$gtm.enable(true), you get the error TypeError: Cannot read property 'defer' of undefined.

I guess this is caused by the missing config object in GtmPlugin.js line 17.

mwicha commented 4 years ago

I found this issue too. Do you found solution to solve this?

mwicha commented 4 years ago

@peXed I found vue-gtm version "2.3.0" is work for me.

peXed commented 4 years ago

@mwicha unfortunately, this is not working for me. I still get the same error. It seems the queryParams are missing in this call.

olzv commented 4 years ago

Facing the same issue. Agree with @peXed that it is caused by missing config parameter: https://github.com/mib200/vue-gtm/blob/master/src/GtmPlugin.js#L17

robgallen commented 4 years ago

Probably caused by #78

thbwd commented 4 years ago

I've hotfixed this in a fork: https://github.com/thbwd/vue-gtm/commit/d0f8f89ee662173f72fd532375e5d5e2e1f19111

Shinigami92 commented 4 years ago

I've hotfixed this in a fork: thbwd@d0f8f89

Can you also pls open a PR?

thbwd commented 4 years ago

@Shinigami92 My fix circumvents the global pluginConfig. I don't fully understand the reason for this global object, but this duplication is just an invitation for more bugs in the future. I can refactor the plug-in to remove this global, if you'd like, otherwise my fix doesn't make much sense.

Shinigami92 commented 4 years ago

Ah ok, let the repo owner decide :)