Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lingobus/vue-gtagjs-directive
Vue directive for Google gtag.js
https://github.com/lingobus/vue-gtagjs-directive
google-analytics google-gtag googleanalytics gtag vue vue-gtagjs vuejs
Last synced: about 2 months ago
JSON representation
Vue directive for Google gtag.js
- Host: GitHub
- URL: https://github.com/lingobus/vue-gtagjs-directive
- Owner: lingobus
- Created: 2017-12-05T15:51:56.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-17T04:30:38.000Z (about 7 years ago)
- Last Synced: 2024-11-07T18:52:58.563Z (about 2 months ago)
- Topics: google-analytics, google-gtag, googleanalytics, gtag, vue, vue-gtagjs, vuejs
- Language: JavaScript
- Size: 18.6 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vue-gtag-directive
Vue directive for Google gtag.js
Install
====
> yarn add vue-gtagjs-directiveUsage
====First, include gtag.js in you page or use [vue-gtagjs](https://github.com/lingobus/vue-gtagjs)
```js
import gtagHelper from 'vue-gtagjs-directive'
gtagHelper.setTrackId('UA-XXXXXXXX-1')
```## gtag('config',GA_TRACK_ID, {page_path:'/path'})
```pug
//- if you have setTrackId, track-id attribute can be omitted
button(v-gtag.config="{page_path:'/path'}", trigger-event="mouseup", :before-send="beforeSend", :after-send="afterSend") test
//- otherwise, track-id is mandatory
button(v-gtag:config="{page_path:'/path'}", track-id="UA-XXXXXXXX-1", trigger-event="mouseup") test
```## gtag('event',EVENT_NAME, {event_category:'CATA','event_label':'Label'})
```pug
button(v-gtag:event="{event_category:'CATA','event_label':'Label'}", event-name="EVENT-NAME") test
```