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

Duplicate GTM initializing in SPA mode #3

Open
Manfies opened this issue Feb 9, 2020 · 8 comments
Open

Duplicate GTM initializing in SPA mode #3

Manfies opened this issue Feb 9, 2020 · 8 comments
Labels
bug Something isn't working fixed with workaround

Comments

@Manfies
Copy link
Contributor

Manfies commented Feb 9, 2020

Hi. If you try to run the nuxt application in SPA mode and open the page, you will get a double GTM submission. You can also see two identical scripts in head. The same thing happens when generating applications in the SPA mode.

Browser Dev Tools - Duplicated GTM scripts

@Manfies Manfies changed the title Duplicate GTM initializing on SPA mode Duplicate GTM initializing in SPA mode Feb 10, 2020
@pi0
Copy link
Member

pi0 commented Feb 10, 2020

Thanks for report @Manfies. Trying to investigate more. Created a repro for vue-meta behaviour:

https://github.com/pi0/nuxt-meta-iife-bug

@pi0 pi0 added the bug Something isn't working label Feb 10, 2020
@reinos
Copy link

reinos commented Feb 17, 2020

I see that this will block the usage of multiple containers...

@tintinthong
Copy link

Hi I actually experienced this problem with @nuxtjs/google-tag-manager (which is now deprecated). I had a default value for specifying my GTM-staging id and an environment value specifying GTM-production. But when I loaded my site with all environment variables intact, I have production and staging GTM running.

I was wondering what is the difference between this repo and @nuxtjs/google-tag-manager. And whether this repo (based on this issue) could have inherited the problem from @nuxtjs/google-tag-manager. Hope you can help.

@pi0
Copy link
Member

pi0 commented Mar 31, 2020

@tintinthong This is a full rewrite using an injected snippet on the page. Also currently a guard is added to the snippet to prevent adding duplicate you can try it :)

@dminchev
Copy link

Hi I'm also have the same issue - duplicated GTM https://take.ms/lwueD
This happens while I'm revisiting pages. The configuration is the basic as in the docs:

buildModules: [   
  '@nuxtjs/gtm'
],
gtm: {
  id: 'GTM-IDHRERE'
}

package.json

"dependencies": {
  "@nuxtjs/gtm": "^2.3.0"
}

@urbgimtam
Copy link

@dminchev I've having the same behaviour. Tags seem to be accumulating per page.
However, if you search for the GTM code in devtools, the code snippet its not repeated.

Could this be a detection bug on the Google Tag Assistant extension itself?

I'm saying this because of the way Nuxt works (where each page you visit is not thrown away - if you disable internet you can still visit the pages you've watched before, etc..), and what I believe to be the expectation of Google Tag Assistant (each page is a single unit).

Also, the data metrics don't seem to be affected.

@urbgimtam
Copy link

I think I've found it.
In default.vue, when using the "keep-alive" attribute on component, the pages remain on memory, thus triggering the multiple scripts. Removing "keep-alive" removed the extra detections on Google Tag Assistant.

@alishahlakhani
Copy link

Hi I'm also have the same issue - duplicated GTM https://take.ms/lwueD
This happens while I'm revisiting pages. The configuration is the basic as in the docs:

buildModules: [   
  '@nuxtjs/gtm'
],
gtm: {
  id: 'GTM-IDHRERE'
}

package.json

"dependencies": {
  "@nuxtjs/gtm": "^2.3.0"
}

Shouldn't we use it as modules and not buildModules? ReadMe suggests so too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed with workaround
Projects
None yet
Development

No branches or pull requests

7 participants