@bchteam/gtm-nuxt

Google Tag Manager module for Nuxt.js

Usage no npm install needed!

<script type="module">
  import bchteamGtmNuxt from 'https://cdn.skypack.dev/@bchteam/gtm-nuxt';
</script>

README

@bchteam/gtm-nuxt

Google Tag Manager module for Nuxt.js

Features

The module enables vue-gtm for Nuxt.js.

The module supports defining options by function with Nuxt context as argument.

Setup

  • Add @bchteam/gtm-nuxt dependency using yarn or npm to your project
  • Add @bchteam/gtm-nuxt to modules section of nuxt.config.js
  • Add options in gtm section of nuxt.config.js or with module.
{
  modules: [
    ['@bchteam/gtm-nuxt', {
      id: (ctx) => ctx.app.$env.GTM_ID,
      enabled: true,
    }]
  ],
  gtm: {
    debug: function (ctx) {
      return ctx.app.$env.GTM_DEBUG === 'true'
    },
    ignoredViews: ['homepage'],
  },
}

Options

Options can be passed in nuxt.config.js. See vue-gtm for details

id

  • Type: String
  • Default: null

enabled

  • Type: Boolean
  • Default: false

debug

  • Type: Boolean
  • Default: false

ignoredViews

  • Type: Array
  • Default: []

License

MIT License

Copyright (c) 2019 Zakharov Sergey zakhse@yandex.ru