UNPKG

1.43 kBMarkdownView Raw
1# Google Tag Manager
2[![npm](https://img.shields.io/npm/dt/@nuxtjs/google-tag-manager.svg?style=flat-square)](https://www.npmjs.com/package/@nuxtjs/google-tag-manager)
3[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/google-tag-manager/latest.svg?style=flat-square)](https://www.npmjs.com/package/@nuxtjs/google-tag-manager)
4
5> Add Google Tag Manager (GTM) to your nuxt.js application.
6This plugins automatically sends first page and route change events to GTM.
7
8**Note:** google tag manager is not enabled in dev mode.
9You can set environment variable `NODE_ENV` to `production` for testing in dev mode.
10
11## Setup
12- Add `@nuxtjs/google-tag-manager` dependency using yarn or npm to your project
13- Add `@nuxtjs/google-tag-manager` to `modules` section of `nuxt.config.js`
14```js
15 modules: [
16 ['@nuxtjs/google-tag-manager', { id: 'GTM-XXXXXXX' }],
17 ]
18```
19
20## Options
21
22### `id`
23- Required
24Should be in form of `GTM-XXXXXXX`
25
26### All options
27```js
28{
29 id: 'GTM-XXXXXXX',
30 layer: 'dataLayer',
31 pageTracking: false
32 query: {
33 // query params...
34 gtm_auth: '...',
35 gtm_preview: '...',
36 gtm_cookies_win: '...'
37 },
38 scriptURL: '//example.com'
39}
40```
41
42### Router Integration
43
44You can optionally set `pageTracking` option to `true` to track page views.
45
46This is disabled by default to prevent double events when using alongside with Google Analytics so take care before enabling this option.