Skip to main content

How to set up Google Analytics 4 (GA4) with Nuxt.js?

Use @nuxtjs/google-gtag.

Using @nuxtjs/google-gtag

Install @nuxtjs/google-gtag

Install the Google Analytics module @nuxtjs/google-gtag in your project.
Run the following command:

npm install --save @nuxtjs/google-gtag

Add the module to nuxt.config.js

Configure Google Analytics in nuxt.config.js.
Open nuxt.config.js and add the following:

nuxt.config.js
  modules: [
'@nuxtjs/google-gtag'
],
'google-gtag': {
id: "G-XXXXXXX",
debug: false
},
caution

Replace G-XXXXXXX with your own tracking ID.

Reference

You can also use @nuxtjs/gtm as an alternative method.
Please refer to the Google Analytics integration documentation for more details.


Support

If you have any other questions, please contact us or check out Our Slack Community.