Google Analytics for Vue.js
Switch branches/tags
Nothing to show
Clone or download
Latest commit b274af5 Dec 24, 2016
Permalink
Failed to load latest commit information.
__test__ init Dec 24, 2016
example init Dec 24, 2016
src init Dec 24, 2016
.babelrc init Dec 24, 2016
.editorconfig init Dec 24, 2016
.gitattributes init Dec 24, 2016
.gitignore init Dec 24, 2016
LICENSE init Dec 24, 2016
README.md update readme Dec 24, 2016
circle.yml init Dec 24, 2016
package.json -> v1.0.0 Dec 24, 2016
yarn.lock init Dec 24, 2016

README.md

vue-ga

NPM version NPM downloads Build Status donate

Simple Google Analytics binding for Vue.js apps, 534 bytes gzipped.

Install

yarn add vue-ga

Usage

vue-router

// ./router/index.js
import VueRouter from 'vue-router'
import ga from 'vue-ga'

Vue.use(VueRouter)

const router = new VueRouter()
ga(router, 'UA-XXXXX-Y')

export default router

non vue-router

It works with all SPA, even in non-Vue apps, just invoke the collect function after route changes, for example:

ga(collect => {
  // when hash changes
  window.onhashchange = () => {
    collect(location.pathname + location.hash)
  }
}, 'UA-XXXXX-Y')

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

vue-ga © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).

egoistian.com · GitHub @egoist · Twitter @rem_rin_rin