@nuxtjs/google-tag-manager

[![npm](https://img.shields.io/npm/dt/@nuxtjs/google-tag-manager.svg?style=flat-square)](https://www.npmjs.com/package/@nuxtjs/google-tag-manager) [![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/google-tag-manager/latest.svg?style=flat-squa

please migrate to https://github.com/nuxt-community/gtm-module
Last updated 8 months ago by pi0 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @nuxtjs/google-tag-manager 
SYNC missed versions from official npm registry.

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.

Setup

  • 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' }],
  ]

Options

id

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

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

All options

{
  id: 'GTM-XXXXXXX',
  layer: 'dataLayer',
  pageTracking: false,
  pageViewEventName: 'nuxtRoute',
  respectDoNotTrack: false,
  dev: true, // set to false to disable in dev mode
  query: {
    // query params...
    gtm_auth:        '...',
    gtm_preview:     '...',
    gtm_cookies_win: '...'
  },
  scriptURL: '//example.com',
  noscriptURL: '//example.com'
}

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.

The default event name for page views is "nuxtRoute", you can change it by setting the pageViewEventName option.

Usage

Pushing events

You can push events into the configured layer:

this.$gtm.pushEvent({ event: 'myEvent', ...someAttributes })

Current Tags

  • 2.3.2                                ...           latest (8 months ago)

21 Versions

  • 2.3.2 [deprecated]           ...           8 months ago
  • 2.4.0 [deprecated]           ...           8 months ago
  • 2.3.1 [deprecated]           ...           a year ago
  • 2.3.0 [deprecated]           ...           a year ago
  • 2.2.1 [deprecated]           ...           a year ago
  • 2.2.0 [deprecated]           ...           2 years ago
  • 2.1.4 [deprecated]           ...           2 years ago
  • 2.1.3 [deprecated]           ...           2 years ago
  • 2.1.2 [deprecated]           ...           2 years ago
  • 2.1.1 [deprecated]           ...           2 years ago
  • 2.1.0 [deprecated]           ...           2 years ago
  • 2.0.0 [deprecated]           ...           2 years ago
  • 1.2.0 [deprecated]           ...           3 years ago
  • 1.1.0 [deprecated]           ...           3 years ago
  • 1.0.1 [deprecated]           ...           3 years ago
  • 1.0.0 [deprecated]           ...           3 years ago
  • 0.0.5 [deprecated]           ...           3 years ago
  • 0.0.4 [deprecated]           ...           3 years ago
  • 0.0.3 [deprecated]           ...           3 years ago
  • 0.0.2 [deprecated]           ...           3 years ago
  • 0.0.1 [deprecated]           ...           3 years ago
Downloads
Today 0
This Week 35
This Month 145
Last Day 9
Last Week 41
Last Month 203
Dependencies (0)
None
Dev Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |