An open API service indexing awesome lists of open source software.

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

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.