https://github.com/james2doyle/vue-ga-directive
A directive for accessing the Google Analytics window.ga object by using params/attributes
https://github.com/james2doyle/vue-ga-directive
Last synced: about 1 year ago
JSON representation
A directive for accessing the Google Analytics window.ga object by using params/attributes
- Host: GitHub
- URL: https://github.com/james2doyle/vue-ga-directive
- Owner: james2doyle
- License: mit
- Created: 2015-12-04T18:53:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-09T22:01:57.000Z (over 10 years ago)
- Last Synced: 2025-04-20T13:06:52.855Z (about 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 13
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vue-ga-directive
A directive for accessing the Google Analytics window.ga object by using attributes.
### Install
Available through npm as `vue-ga-directive`. Or include as an inline script, like in `example.html`.
### Demo
You can load up the `example.html` file here to test the directive.
### Usage
Here is how you might typically use this directive:
```html
Fire Click Event
```
You can see we have `v-ga-event` which is listening for a `click` and it will also trigger `event.preventDefault()`. This is the same format as normal Vue `v-on:*` events.
Next we have the `v-ga-value` property. This is a positive Int that will be passed to the event. [Read the docs for more on eventValue](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#eventValue).
The last item is `v-ga-callback`. This will trigger that function in your current `Vue.vm`. It is like calling `this.myVmFunction(directiveInstance, event.target)`. For example, you might want to track the event, and then when the request is done, trigger a form submit or fetch a piece of data.
You can see a `Vue` instance in `js/main.js` if you want more details.