Branch: master
Find file History
pi0 Publish
 - @nuxtjs/google-tag-manager@2.1.4
Latest commit 0fb865d Feb 12, 2019

Google Tag Manager

npm npm (scoped with tag)

Add Google Tag Manager (GTM) to your nuxt.js application. This plugins automatically sends first page and route change events to GTM.

Note: google tag manager is not enabled in dev mode. You can set environment variable NODE_ENV to production for testing in dev mode.


  • Add @nuxtjs/google-tag-manager dependency using yarn or npm to your project
  • Add @nuxtjs/google-tag-manager to modules section of nuxt.config.js
  modules: [
   ['@nuxtjs/google-tag-manager', { id: 'GTM-XXXXXXX' }],



  • Required
  • Can be String in form of GTM-XXXXXXX
  • Can be function returning Promise or String:
// Returns Promise
id: () => {
  return axios.get('')
    .then(({ data }) => {
      return data.gtm_id

// Returns String
const code = '1234567'
id: () => {
  return 'GTM-' + code

All options

  id: 'GTM-XXXXXXX',
  layer: 'dataLayer',
  pageTracking: false
  query: {
    // query params...
    gtm_auth:        '...',
    gtm_preview:     '...',
    gtm_cookies_win: '...'
  scriptURL: '//'

Router Integration

You can optionally set pageTracking option to true to track page views.

This is disabled by default to prevent double events when using alongside with Google Analytics so take care before enabling this option.