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

@analytics/google-tag-manager adds gtag to gtm.js as well #359

Open
Carduelis opened this issue Feb 9, 2023 · 2 comments
Open

@analytics/google-tag-manager adds gtag to gtm.js as well #359

Carduelis opened this issue Feb 9, 2023 · 2 comments

Comments

@Carduelis
Copy link

While @analytics/google-tag-manager should add only gtm.js script, I see in my HTML also gtag.

I'm not sure it's a part of the package, since I wasn't able to find any evidence in the source code of the library, but I am curious, why gtm adds gtag as well. Due to this fact, the performance of the page is affected.

image

@Carduelis
Copy link
Author

Carduelis commented Feb 9, 2023

To make it clearer, I have a couple of questions:

  1. Does gtm.js add gtag/js automatically? (Looks like it is "yes", since gtm.js contains the G-xxxxxx key inside
  2. Is this behavior intentional? I read a lot that we do not need both tags, and they claim it's bad to add both
  3. Is there a way to have a certain setting in @analytics/google-tag-manager to manage the behavior?
  4. I bet @analytics/google-tag-manager needs a Readme about this behavior.

Because, it looks like @analytics/google-tag-manager also behaves like @analytics/google-analytics (which v4)

import Analytics from 'analytics'
import googleAnalyticsPlugin from '@analytics/google-analytics'
import googleAnalyticsV3Plugin from '@analytics/google-analytics-v3'

/* Initialize analytics instance */
const analytics = Analytics({
  app: 'my-app',
  plugins: [
    /* Load Google Analytics v4 */
    googleAnalyticsPlugin({
      measurementIds: ['G-abc123'],  // this is the `G-xxxxx` key i have in my setup
    }),
  ],
})

analytics.page()

@Carduelis Carduelis changed the title @analytics/google-tag-manager adds gtag.js as well @analytics/google-tag-manager adds gtag.js to gtm.js as well Feb 9, 2023
@Carduelis Carduelis changed the title @analytics/google-tag-manager adds gtag.js to gtm.js as well @analytics/google-tag-manager adds gtag to gtm.js as well Feb 9, 2023
@DavidWells
Copy link
Owner

GTM only adds one script tag here https://github.com/DavidWells/analytics/blob/master/packages/analytics-plugin-google-tag-manager/src/browser.js#L66

It sounds like your google tag script is added the additional script. Check your container ID and verify what it's loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants