Skip to content

Releases: johannschopplich/nuxt-gtag

v2.0.0

27 Feb 11:16
Compare
Choose a tag to compare

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

   🚀 Features

    View changes on GitHub

v1.2.1

22 Feb 12:43
Compare
Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub

v1.2.0

09 Feb 12:36
Compare
Choose a tag to compare

   🚀 Features

   🐞 Bug Fixes

   🏎 Performance

    View changes on GitHub

v1.1.2

20 Dec 13:23
Compare
Choose a tag to compare

   🚀 Features

    View changes on GitHub

v1.1.1

15 Sep 13:57
Compare
Choose a tag to compare

   🚀 Features

    View changes on GitHub

v1.1.0

09 Sep 21:13
Compare
Choose a tag to compare

   🚀 Features

    View changes on GitHub

v1.0.0

08 Sep 21:06
Compare
Choose a tag to compare

   🚨 Breaking Changes

    View changes on GitHub

v0.6.3

08 Sep 08:13
Compare
Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub

v0.6.2

29 Aug 09:23
Compare
Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub

v0.6.1

15 Aug 09:38
Compare
Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub