Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/egoist/vue-ga
Google Analytics for Vue.js
https://github.com/egoist/vue-ga
google-analytics vue
Last synced: 4 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 (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T14:35:20.000Z (about 2 years ago)
- Last Synced: 2024-12-02T13:19:08.830Z (19 days ago)
- Topics: google-analytics, vue
- Language: JavaScript
- Homepage:
- Size: 333 KB
- Stars: 141
- Watchers: 6
- Forks: 11
- 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
[![NPM version](https://img.shields.io/npm/v/vue-ga.svg?style=flat-square)](https://npmjs.com/package/vue-ga) [![NPM downloads](https://img.shields.io/npm/dm/vue-ga.svg?style=flat-square)](https://npmjs.com/package/vue-ga) [![Build Status](https://img.shields.io/circleci/project/egoist/vue-ga/master.svg?style=flat-square)](https://circleci.com/gh/egoist/vue-ga) [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000&style=flat-square)](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)