nuxt-gtag

🔸 Google Tag integration for Nuxt: Google Analytics, Google Ads and more

MIT License

Downloads
118.2K
Stars
272

Bot releases are visible (Hide)

nuxt-gtag - v3.0.1 Latest Release

Published by github-actions[bot] about 2 months ago

   🚀 Features

    View changes on GitHub
nuxt-gtag - v3.0.0

Published by github-actions[bot] about 2 months ago

   🚨 Breaking Changes

  • initMode for manual Gtag initialization  -  by @johannschopplich (f9080)

   ℹ️ Migration

In v2.x and earlier, the enabled option was used to control manual initialization of the Google tag script. This option has been replaced with initMode in v3.x. To migrate your configuration, set the initMode option to manual:

export default defineNuxtConfig({
  modules: ['nuxt-gtag'],

  gtag: {
-    enabled: false,
+    initMode: 'manual',
    id: 'GX-XXXXXXXXXX'
  }
})

The enabled option is still available in v3.x, but is now used to disable the Google tag module for the current environment. This is useful if you want to disable the module in development or staging environments:

export default defineNuxtConfig({
  modules: ['nuxt-gtag'],

  gtag: {
    enabled: process.env.NODE_ENV === 'production',
    id: 'G-XXXXXXXXXX'
  }
})
    View changes on GitHub
nuxt-gtag - v2.1.0

Published by github-actions[bot] 3 months ago

   🚀 Features

    View changes on GitHub
nuxt-gtag - v2.0.7

Published by github-actions[bot] 3 months ago

   🐞 Bug Fixes

    View changes on GitHub
nuxt-gtag - v2.0.6

Published by github-actions[bot] 5 months ago

   🐞 Bug Fixes

    View changes on GitHub
nuxt-gtag - v2.0.5

Published by github-actions[bot] 7 months ago

   🐞 Bug Fixes

    View changes on GitHub
nuxt-gtag - v2.0.4

Published by github-actions[bot] 8 months ago

   🏎 Performance

  • Resolve options raw once  -  by @johannschopplich (0e4bb)
    View changes on GitHub
nuxt-gtag - v2.0.3

Published by github-actions[bot] 8 months ago

   🐞 Bug Fixes

  • Resolve raw options  -  by @johannschopplich (58507)
    View changes on GitHub
nuxt-gtag - v2.0.2

Published by github-actions[bot] 8 months ago

   🐞 Bug Fixes

    View changes on GitHub
nuxt-gtag - v2.0.1

Published by github-actions[bot] 8 months ago

No significant changes

    View changes on GitHub
nuxt-gtag - v2.0.0

Published by github-actions[bot] 8 months ago

Migration Guide

The latest version of Nuxt Gtag improves the API and adds support for Google Tag Consent Mode v2. This migration guide will help you to upgrade your project from the previous version to the latest one.

Migrating initialConsent

This module option has been renamed to enabled. If you have set initialConsent to false in your configuration, you should rename it to enabled.

export default defineNuxtConfig({
  modules: ['nuxt-gtag'],

  gtag: {
    id: 'G-XXXXXXXXXX',
-    initialConsent: false
+    enabled: false
  }
})

Migrating grantConsent

This function has been renamed to initialize. If you have used grantConsent in your project, you should rename it to initialize.

const { 
    gtag,
-    grantConsent
+    initialize
} = useGtag()

- grantConsent()
+ initialize()

Migrating revokeConsent

Before v2, grantConsent and revokeConsent were used to enable and disable analytics. But the abstraction was not clear, because they didn't work for other Google products like Google Ads.

Now, you can use enableAnalytics and disableAnalytics to enable and disable analytics.

New: Google Consent Mode

[!TIP]
Follows the Google Consent Mode v2 specification.

Set a default value for each consent type you are using. By default, no consent mode values are set.

The following example sets multiple consent mode parameters to denied by default:

export default defineNuxtConfig({
  modules: ['nuxt-gtag'],

  gtag: {
    id: 'G-XXXXXXXXXX',
    initCommands: [
      // Setup up consent mode
      ['consent', 'default', {
        ad_user_data: 'denied',
        ad_personalization: 'denied',
        ad_storage: 'denied',
        analytics_storage: 'denied',
        wait_for_update: 500,
      }]
    ]
  }
})

After a user indicates their consent choices, update relevant parameters to granted:

function allConsentGranted() {
  const { gtag } = useGtag()
  gtag('consent', 'update', {
    ad_user_data: 'granted',
    ad_personalization: 'granted',
    ad_storage: 'granted',
    analytics_storage: 'granted'
  })
}

function consentGrantedAdStorage() {
  const { gtag } = useGtag()
  gtag('consent', 'update', {
    ad_storage: 'granted'
  })
}

// Invoke the consent function when a user interacts with your banner
consentGrantedAdStorage() // Or `allConsentGranted()`

   🚨 Breaking Changes

  • Rename initialConsent to enabled  -  by @johannschopplich (b342e)
  • Rename grantConsent to initialize  -  by @johannschopplich (3bd75)
  • disableAnalytics and enableAnalytics  -  by @johannschopplich (998fe)

   🚀 Features

  • Google tag consent mode v2  -  by @johannschopplich (903b9)
  • initCommands  -  by @johannschopplich (d9706)
    View changes on GitHub
nuxt-gtag - v1.2.1

Published by github-actions[bot] 8 months ago

   🐞 Bug Fixes

    View changes on GitHub
nuxt-gtag - v1.2.0

Published by github-actions[bot] 8 months ago

   🚀 Features

   🐞 Bug Fixes

  • Resolve runtime options in client  -  by @johannschopplich (49f9a)
  • Init all tags when granting consent  -  by @johannschopplich (acd0b)

   🏎 Performance

  • Load client plugin in parallel  -  by @johannschopplich (b7af8)
    View changes on GitHub
nuxt-gtag - v1.1.2

Published by github-actions[bot] 10 months ago

   🚀 Features

  • Log missing Google analytics ID  -  by @johannschopplich (59a63)
    View changes on GitHub
nuxt-gtag - v1.1.1

Published by github-actions[bot] about 1 year ago

   🚀 Features

    View changes on GitHub
nuxt-gtag - v1.1.0

Published by github-actions[bot] about 1 year ago

   🚀 Features

  • Complete gtag.js type definitions  -  by @johannschopplich (8a0dc)
    View changes on GitHub
nuxt-gtag - v1.0.0

Published by github-actions[bot] about 1 year ago

   🚨 Breaking Changes

  • Remove useGtagConsent composable  -  by @johannschopplich (cb74a)
  • useGtag composable to destructure grantConsent, revokeConsent & gtag  -  by @johannschopplich (00ee2)
    View changes on GitHub
nuxt-gtag - v0.6.3

Published by github-actions[bot] about 1 year ago

   🐞 Bug Fixes

  • Add explicit composable imports  -  by @johannschopplich (9a008)
    View changes on GitHub
nuxt-gtag - v0.6.2

Published by github-actions[bot] about 1 year ago

   🐞 Bug Fixes

    View changes on GitHub
nuxt-gtag - v0.6.1

Published by github-actions[bot] about 1 year ago

   🐞 Bug Fixes

  • Add missing defineNuxtPlugin import  -  by @johannschopplich (58f04)
    View changes on GitHub