vue-ga
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
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- 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