All Projects → nuxt-community → Google Gtag Module

nuxt-community / Google Gtag Module

Licence: mit
Enable google gtagjs for NuxtJs

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Google Gtag Module

Sails Nuxt
Sails + Nuxt + Vuetify Combo <3
Stars: ✭ 92 (-13.21%)
Mutual labels:  nuxt, nuxtjs
Vue Svg Inline Loader
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
Stars: ✭ 105 (-0.94%)
Mutual labels:  nuxt, nuxtjs
Laravel Vuejs.com
Laravel and VueJs Blog, using Laravel nova, GraphQL, NuxtJs, Apollo and ...more
Stars: ✭ 54 (-49.06%)
Mutual labels:  nuxt, nuxtjs
Pwa Module
Zero config PWA solution for Nuxt.js
Stars: ✭ 1,033 (+874.53%)
Mutual labels:  nuxt, nuxtjs
Nuxt Netlify
Dynamically generate `_headers` and `_redirects` files for Netlify in your Nuxt.js projects
Stars: ✭ 97 (-8.49%)
Mutual labels:  nuxt, nuxtjs
Eslint Module
ESLint module for Nuxt.js
Stars: ✭ 49 (-53.77%)
Mutual labels:  nuxt, nuxtjs
Example Ecommerce Snipcart Vue
The Transglobal Candy Store: Sample front-end for the Sanity.io e-commerce schema with vue.js, nuxt.js, and snipcart
Stars: ✭ 89 (-16.04%)
Mutual labels:  nuxt, nuxtjs
Quickjam
Starter template for Nuxt apps bundled with an API
Stars: ✭ 42 (-60.38%)
Mutual labels:  nuxt, nuxtjs
Nuxt Chat App
Frontend of real-time chat application built using nuxtjs, socket.io. Check the backend at https://github.com/binbytes/chat-app-server.
Stars: ✭ 77 (-27.36%)
Mutual labels:  nuxt, nuxtjs
Docker Nuxt
Docker image to run NUXT.js application in production mode
Stars: ✭ 71 (-33.02%)
Mutual labels:  nuxt, nuxtjs
Nuxt Box
Truffle, Nuxt and Vue boilerplate
Stars: ✭ 46 (-56.6%)
Mutual labels:  nuxt, nuxtjs
Nuxt Graphql Request
Easy Minimal GraphQL client integration with Nuxt.js.
Stars: ✭ 85 (-19.81%)
Mutual labels:  nuxt, nuxtjs
Realworld Nuxt
Nuxt.js implementation of RealWorld Frontend
Stars: ✭ 45 (-57.55%)
Mutual labels:  nuxt, nuxtjs
Nuxt User Agent
Nuxt.js module for handling User-Agent.
Stars: ✭ 102 (-3.77%)
Mutual labels:  nuxt, nuxtjs
Virapro.ru
[E-commerce] Plumbing Store
Stars: ✭ 45 (-57.55%)
Mutual labels:  nuxt, nuxtjs
Nuxt Compress
A simple static asset compression module for Nuxt that runs Gzip and Brotli compression during the build process
Stars: ✭ 61 (-42.45%)
Mutual labels:  nuxt, nuxtjs
Iblog
基于 Node.js 的开源个人博客系统,采用 Nuxt + Vue + TypeScript 技术栈。
Stars: ✭ 994 (+837.74%)
Mutual labels:  nuxt, nuxtjs
Nuxt Template
🗃 Nuxt Template (Typescript + Composition API)
Stars: ✭ 40 (-62.26%)
Mutual labels:  nuxt, nuxtjs
Nuxt Tailwind
A Nuxt.js starter project template using Tailwind CSS without the distraction of a complicated development environment.
Stars: ✭ 71 (-33.02%)
Mutual labels:  nuxt, nuxtjs
Vue Masonry Wall
A pure vue responsive masonry layout without direct dom manipulation and ssr support.
Stars: ✭ 79 (-25.47%)
Mutual labels:  nuxt, nuxtjs

@nuxtjs/google-gtag

npm version npm downloads Circle CI Codecov License

Google official gtagjs for Nuxt.js

📖 Release Notes

Attention

This project is looking for maintainers. Please see RFC for future of module.

Features

The module includes Google googletagmanager.com/gtag/js into your project and enables it with config you pass in as options.

  • Check the official reference gtagjs

Setup

  1. Add @nuxtjs/google-gtag dependency to your project
yarn add @nuxtjs/google-gtag # or npm install @nuxtjs/google-gtag
  1. Add @nuxtjs/google-gtag to the modules section of nuxt.config.js
{
  modules: [
    // Simple usage
    '@nuxtjs/google-gtag',

    // With options
    ['@nuxtjs/google-gtag', { /* module options */ }]
  ]
}

Using top level options

{
  modules: [
    '@nuxtjs/google-gtag'
  ],
  'google-gtag': {
    id: 'UA-XXXX-XX',
    config: {
      anonymize_ip: true, // anonymize IP 
      send_page_view: false, // might be necessary to avoid duplicated page track on page reload
      linker: {
        domains: ['domain.com','domain.org']
      }
    },
    debug: true, // enable to track in dev mode
    disableAutoPageTrack: false, // disable if you don't want to track each page route with router.afterEach(...).
    additionalAccounts: [{
      id: 'AW-XXXX-XX', // required if you are adding additional accounts
      config: {
        send_page_view: false // optional configurations
      }
    }]
  }
}

Options

id (required)

Google Analytics property ID.

config

  • Default: {}

Config options for gtagjs

debug

  • Default: false

Enable to track in dev mode.

disableAutoPageTrack

  • Default: false

Disable if you don't want to track each page route with router.afterEach(...).

additionalAccounts

  • Default: []

You can add more configuration like AdWords

Usage

This module includes Google gtag in your NuxtJs project and enables every page tracking by default. You can use gtag inside of your components/functions/methods like follow:

this.$gtag('event', 'your_event', { /* track something awesome */})

To make sure that every page is tracked correctly

As the router code sometimes runs before head data is set correctly you can use following approach to make sure that everything is set correctly:

// make sure to set disableAutoPageTrack: true inside of nuxt.config.js
// inside of your Page.vue/Layout.vue file
 mounted() {
    if (process.browser) {
      this.$gtag('config', 'UA-XXXX-XXX', {
        page_title: this.$metaInfo.title,
        page_path: this.$route.fullPath,
      })
    }
  }

See official docs:

Check functionalities

Install Google Tag Assistant and see if your page is being tracked.

Development

  • Clone this repository
  • Install dependencies using yarn install or npm install
  • Start development server using npm run dev

License

MIT License

Copyright (c) Nuxt Community

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].