From 97ec1efce2bdffd7eeadbbb024fc6f3ffaebfb1e Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 8 Jun 2018 19:50:41 +0200 Subject: Add GA events --- src/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index 18eb719..9f511cf 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,7 @@ import VueRouter from 'vue-router'; import Buefy from 'buefy' import 'buefy/lib/buefy.css' import Ads from 'vue-google-adsense'; +import VueAnalytics from 'vue-analytics' import App from './App.vue'; import ModeTab from './ModeTab.vue'; @@ -12,8 +13,8 @@ import ModeTab from './ModeTab.vue'; Vue.use(VueRouter); Vue.use(Buefy); -Vue.use(require('vue-script2')) -Vue.use(Ads.Adsense) +Vue.use(require('vue-script2')); +Vue.use(Ads.Adsense); const router = new VueRouter({ routes: [ { @@ -23,14 +24,27 @@ const router = new VueRouter({ } ] }); +Vue.use(VueAnalytics, { + id: 'UA-118868480-1', + router, + debug: { + sendHitTask: process.env.NODE_ENV === 'production', + enabled: process.env.NODE_ENV !== 'production', + } +}); + new Vue({ router, el: '#app', render: h => h(App), mounted: function() { + if (window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone === true) { + this.$ga.event('PWA', 'started'); + } if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/service-worker.js').then((registration) => { if (typeof registration.update == 'function') { + this.$ga.event('PWA', 'update'); registration.update(); } }); -- cgit v1.3.1