Google Analytics for Vue.js

To add Google Analytics to your hosting site using Vue.js, set tracking code on each page if you need.

It'll be messy if you do that without thinking.

vue-analytics package is beneficial for measuring pages.



  • Vue ^2.0.0
  • Google Analytics Tracking ID


Install the library using npm.

% npm install vue-analytics


Enable auto page tracking with few implementation.

import Vue from 'vue'
import VueAnalytics from 'vue-analytics'

import router from './path-to-router'

/* or meke `router`
import VueRouter from 'vue-router'

const router = new VueRouter({
  router: // ...
Vue.use(VueAnalytics, {

The code is the easiest way to track your pages. vue-analytics can be customized in several ways, refer to other resources.

Other Resources.

Please read the following link if you want to know more tracking!