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

No performance gain using GTM / Google Analytics #272

Closed
ejerskov opened this issue Sep 18, 2024 · 3 comments
Closed

No performance gain using GTM / Google Analytics #272

ejerskov opened this issue Sep 18, 2024 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@ejerskov
Copy link

📚 What are you trying to do?

As I understand it, @nuxt/script should give better performance using the embedded third-party scripts.

However when I use GTM or GoogleAnalytics I see the same hit in PageSpeed reports as using the "vanilla" scripts:
image

I've done the simple implementation of adding this in my App.vue:
GTM:

useScriptGoogleTagManager({
  id: 'GTM-WHHKRNTJ',
})

Google Analytics:

useScriptGoogleAnalytics({
  id: 'G-0HXKBMGTW0',
})

Have I misunderstood the concept of this package?

🔍 What have you tried?

No response

ℹ️ Additional context

No response

@ejerskov ejerskov added the help wanted Extra attention is needed label Sep 18, 2024
@melasculla
Copy link

melasculla commented Sep 18, 2024

image

image

for me the same

$production: {
    scripts: {
      registry: {
        googleTagManager: {
          scriptOptions: {
            tagPosition: 'bodyClose',
          },
          id: id,
        }
      }
    }
  }

@harlan-zw
Copy link
Collaborator

Hi, thanks for the issue. You should understand that Nuxt Scripts's performance optimizations are micro at best, they just allow Nuxt to start before loading in other scripts.

The fact is you're still loading in 104kb of scripts just for GTM, for reference Nuxt itself is only like ~50kb iirc.

My suggestion is to drop GTM if you're only using it as a container for GA, then wait for either one of these that will provide significant improvements:

@ejerskov
Copy link
Author

Ok, thanks for clearing that up @harlan-zw.

I ended up implementing partytown instead of @nuxt/scripts but will look forward to it being embedded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants