From ea922e7a01695398177326840ed7f4bbae28bc86 Mon Sep 17 00:00:00 2001 From: terichadbourne Date: Wed, 10 Jul 2019 11:07:16 -0400 Subject: [PATCH 1/2] update router to display dest route --- src/main.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.js b/src/main.js index 4be383023..f6307c978 100644 --- a/src/main.js +++ b/src/main.js @@ -101,6 +101,10 @@ const router = new VueRouter({ } }) +router.afterEach((to, from, next) => { + console.log("to", to.path) +}) + Vue.config.productionTip = false new Vue({ From 9f34324133e263a4093ac555df7265920d809494 Mon Sep 17 00:00:00 2001 From: terichadbourne Date: Wed, 10 Jul 2019 13:56:50 -0400 Subject: [PATCH 2/2] enable page view tracking via Countly --- public/index.html | 50 +++++++++++++++++++++++++++++------------------ src/main.js | 6 ++++-- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/public/index.html b/public/index.html index 4f72247f5..954b11214 100644 --- a/public/index.html +++ b/public/index.html @@ -53,27 +53,39 @@ } return dntStatus === 'Enabled' } - /* From https://github.com/nodejs/nodejs.org/blob/703bacbc0da63fa91f156468209758c66c01f30f/layouts/partials/footer.hbs */ + + //some default pre init + var Countly = Countly || {}; + Countly.q = Countly.q || []; + (function(){ + + // ************ FOR TESTING ONLY ************************ + // Uncomment line below for testing, comment out for deployment + // if (!_dntEnabled()) { + // ******************************************************* + + // *********** FOR DEPLOYMENT ***************************** + // Comment out line below for testing, uncomment for deployment if (!_dntEnabled() && location.hostname === 'proto.school') { - !function(n,o,d,e,j,s){n.GoogleAnalyticsObject=d;n[d]||(n[d]=function(){ - (n[d].q=n[d].q||[]).push(arguments)});n[d].l=+new Date;j=o.createElement(e); - s=o.getElementsByTagName(e)[0];j.async=1;j.src='//www.google-analytics.com/analytics.js'; - s.parentNode.insertBefore(j,s)}(window,document,'ga','script'); - if (!ga) return; - ga('create', 'UA-96910779-4', 'auto'); - ga('send', 'pageview'); - document.documentElement.addEventListener('click', function(e) { - // Track case studies - if(!e.target || !e.target.dataset || !e.target.dataset.casestudy) return; - ga('send', 'event', { - eventCategory: 'casestudy', - eventAction: 'click', - eventLabel: e.target.dataset.casestudy, - eventValue: 0 - }); - }); - } + // ******************************************************* + + //provide countly initialization parameters + Countly.app_key = 'c785b6eaa9c61617e1a7db83cb437e5f3dfe4280'; + Countly.url = 'https://countly.ipfs.io'; + + Countly.q.push(['track_sessions']); + Countly.q.push(['track_pageview']); + Countly.q.push(['track_clicks']); + + //load countly script asynchronously + var cly = document.createElement('script'); cly.type = 'text/javascript'; + cly.async = true; + //enter url of script here + cly.src = 'https://countly.ipfs.io/sdk/web/countly.min.js'; + cly.onload = function(){Countly.init()}; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s); + } })(); diff --git a/src/main.js b/src/main.js index f6307c978..24a18a3bb 100644 --- a/src/main.js +++ b/src/main.js @@ -101,8 +101,10 @@ const router = new VueRouter({ } }) -router.afterEach((to, from, next) => { - console.log("to", to.path) +// track page view via Countly when route changes +router.afterEach((to) => { + if (!window.Countly) return + window.Countly.q.push(['track_pageview', to.path]) }) Vue.config.productionTip = false