vue-ga

1.1.0 • Public • Published

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

/vue-ga/

    Package Sidebar

    Install

    npm i vue-ga

    Weekly Downloads

    166

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    7.58 kB

    Total Files

    7

    Last publish

    Collaborators

    • egoist
    • rem