Vue directive for Google gtag.js
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
.babelrc
.gitignore
README.md
package.json
yarn.lock

README.md

vue-gtag-directive

Vue directive for Google gtag.js

Install

yarn add vue-gtagjs-directive

Usage

First, include gtag.js in you page or use vue-gtagjs

import gtagHelper from 'vue-gtagjs-directive'
gtagHelper.setTrackId('UA-XXXXXXXX-1')

gtag('config',GA_TRACK_ID, {page_path:'/path'})

//- 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'})

button(v-gtag:event="{event_category:'CATA','event_label':'Label'}", event-name="EVENT-NAME") test