johannschopplich / nuxt-gtag

🔸 Google Analytics & Ads integration made easy
https://developers.google.com/tag-platform/gtagjs
MIT License
298 stars 9 forks source link

Google Tag: GTM-XXXXXX not found #80

Closed bjarnef closed 2 months ago

bjarnef commented 2 months ago

Environment

-

Reproduction

-

Describe the bug

We have the following config in Nuxt.

runtimeConfig: {
    public: {
        gtag: {
            id: 'GTM-XXXXXXX'
        }
    },
},

and this under modules:

modules: ['@pinia/nuxt', '@nuxt/image', 'nuxt-primevue', '@nuxtjs/fontaine', '@nuxtjs/sitemap', 'nuxt-gtag'],

I inject Google Tag Manager script into <head>

<script src="https://www.googletagmanager.com/gtag/js?id=GTM-XXXXXXX" defer="" data-gtag="true"></script>

However when debugging using Google Tag Assistant, it doesn't find/load the tag.

image

Is the anything to do about this.

Furthermore our marketing people ask to insert the standard script instead, which seems to do a bit more. Is it possible to insert this directly instead?

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'[https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f)](https://www.googletagmanager.com/gtm.js?id=%27+i+dl;f.parentNode.insertBefore(j,f));
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->

Additional context

No response

Logs

No response

johannschopplich commented 2 months ago

Hi there! This module is intended for Google libraries supporting the Google Tag, such as Analytics, not the Google Tag Manager.

urbgimtam commented 1 month ago

Would you please updated the docs so to explicitly inform this? As it stands, after reading:

🛍️ Use Google Analytics 4, Google Ads and other products 🔢 Supports multiple tag IDs

I also thought it would support Google Tag Manager.