mib200 / vue-gtm

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

Load script condition not restrictive enough #93

Closed Jrmyy closed 4 years ago

Jrmyy commented 4 years ago

Hi,

First of all thanks for this plugin, it is really helpful.

Nevertheless, I think I just found an issue in the code. I want to have both Google Tag Manager and Google Analytics. Therefore I have 2 plugins, yours for GTM and an other one (vue-gtag) for GA.

I cannot make them both work because when I have the gtag plugin bootstraping it created in the DOM :

<link href="https://www.googletagmanager.com" rel="preconnect">
<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-167136627-1" charset="utf-8"></script>

But, since the condition for loading the gtm script is :

export const hasScript = function () {
  return Array
    .from(document.getElementsByTagName('script'))
    .some(script => script.src.includes('googletagmanager'))
}

It makes the both plugins incompatible. Is it possible to change the condition to ?

script.src.includes('googletagmanager.com/gtm.js')
Shinigami92 commented 4 years ago

Do you want to open a PR for that? (https://github.com/mib200/vue-gtm/issues/92#issuecomment-683601021)

Jrmyy commented 4 years ago

Sure, I just made it : https://github.com/mib200/vue-gtm/pull/94

Shinigami92 commented 4 years ago

Seems my access to this repo is working great 👍

Released v2.3.4

Thanks for using our plugin 🙂