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:

  modules: [
'google-gtag': {
id: "G-XXXXXXX",
debug: false

Replace G-XXXXXXX with your own tracking ID.


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


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