https://github.com/egoist/vue-ga
Google Analytics for Vue.js
https://github.com/egoist/vue-ga
google-analytics vue
Last synced: 8 days ago
JSON representation
Google Analytics for Vue.js
- Host: GitHub
- URL: https://github.com/egoist/vue-ga
- Owner: egoist
- License: mit
- Created: 2016-12-24T07:40:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T14:35:20.000Z (over 2 years ago)
- Last Synced: 2025-03-24T08:17:57.514Z (23 days ago)
- Topics: google-analytics, vue
- Language: JavaScript
- Homepage:
- Size: 333 KB
- Stars: 141
- Watchers: 5
- Forks: 10
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-vue-js - Google Analytics for Vue.js
README
# vue-ga
[](https://npmjs.com/package/vue-ga) [](https://npmjs.com/package/vue-ga) [](https://circleci.com/gh/egoist/vue-ga) [](https://github.com/egoist/donate)
Simple Google Analytics binding for Vue.js apps, 534 bytes gzipped.
## Install
```bash
yarn add vue-ga
```## Usage
### vue-router
```js
// ./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:
```js
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](https://github.com/egoist), Released under the [MIT](https://egoist.mit-license.org/) License.
Authored and maintained by EGOIST with help from contributors ([list](https://github.com/egoist/vue-ga/contributors)).> [egoistian.com](https://egoistian.com) · GitHub [@egoist](https://github.com/egoist) · Twitter [@rem_rin_rin](https://twitter.com/rem_rin_rin)