From 25fa3942ac6034141ef1dc6c1b43a9dc165343b6 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Wed, 18 Jan 2023 14:00:57 +0000 Subject: [PATCH 1/3] Switch from GA to Cabin. --- components/BusinessPage.vue | 6 +++--- mixins/cabin.js | 16 ++++++++++++++++ mixins/global.js | 2 +- nuxt.config.js | 15 ++++----------- package-lock.json | 13 ------------- package.json | 1 - 6 files changed, 24 insertions(+), 29 deletions(-) create mode 100644 mixins/cabin.js diff --git a/components/BusinessPage.vue b/components/BusinessPage.vue index d8e33cc..4009336 100644 --- a/components/BusinessPage.vue +++ b/components/BusinessPage.vue @@ -401,13 +401,13 @@ export default { this.busy = false // Track the search. - this.$ga.event( + this.cabin( 'search', 'submit_' + this.region, this.category || 'All Categories' ) - this.$ga.event( + this.cabin( 'search', 'location_' + this.region, this.location || 'No location' @@ -421,7 +421,7 @@ export default { const value = [business.name, business.address, business.postcode].join( ', ' ) - this.$ga.event('map', 'select_' + this.region, value) + this.cabin('map', 'select_' + this.region, value) }, showMoreInfo() { this.waitForRef('moreinfomodal', () => { diff --git a/mixins/cabin.js b/mixins/cabin.js new file mode 100644 index 0000000..bb81e25 --- /dev/null +++ b/mixins/cabin.js @@ -0,0 +1,16 @@ +import Vue from 'vue' + +Vue.mixin({ + methods: { + cabin(event, p1, p2) { + console.log('Event', event, p1, p2) + window.cabin.event( + JSON.stringify({ + event, + p1, + p2, + }) + ) + }, + }, +}) diff --git a/mixins/global.js b/mixins/global.js index ed1540d..ff42b09 100644 --- a/mixins/global.js +++ b/mixins/global.js @@ -42,7 +42,7 @@ Vue.mixin({ } }, trackOutboundLink(url) { - this.$ga.event('outbound', 'click_' + this.region, url) + this.cabin('outbound', 'click_' + this.region, url) }, buildHead(title, description, image) { const meta = [ diff --git a/nuxt.config.js b/nuxt.config.js index 57fe611..c0ce29a 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -29,12 +29,16 @@ export default { href: 'https://fonts.googleapis.com/css?family=Poppins', }, ], + script: [ + { src: 'https://scripts.withcabin.com/hello.js', ssr: false, defer: true }, + ] }, css: ['@/assets/css/global.scss'], plugins: [ { src: '~/mixins/global.js' }, + { src: '~/mixins/cabin.js' }, { src: '~/plugins/axios-baseurl' }, { src: '@/plugins/vue-google-maps', ssr: false }, { src: '@/plugins/vue2-leaflet', ssr: false }, @@ -47,7 +51,6 @@ export default { buildModules: [ '@nuxtjs/eslint-module', - '@nuxtjs/google-analytics', '@nuxtjs/google-fonts', ], @@ -148,16 +151,6 @@ export default { }, }, - googleAnalytics: { - id: 'UA-46050944-3', - - // Enable debug in development mode so that we can see what events are tracked. - debug: { - enabled: process.env.NODE_ENV !== 'production', - sendHitTask: true, - }, - }, - googleFonts: { families: { 'Patua One': [300, 400, 600], diff --git a/package-lock.json b/package-lock.json index 433dfc1..31299b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1880,14 +1880,6 @@ "eslint-loader": "^4.0.2" } }, - "@nuxtjs/google-analytics": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@nuxtjs/google-analytics/-/google-analytics-2.4.0.tgz", - "integrity": "sha512-rDQTwHIjyjVrx8GywHPuWykJ3jRFGaHl5Iqji/y8tQWUc0yGEeHxOoR0yimzxnTS1Ph2/PubQYpgnVeEPEdL/A==", - "requires": { - "vue-analytics": "^5.22.1" - } - }, "@nuxtjs/google-fonts": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@nuxtjs/google-fonts/-/google-fonts-1.2.0.tgz", @@ -11708,11 +11700,6 @@ "resolved": "https://registry.npmjs.org/vue/-/vue-2.6.12.tgz", "integrity": "sha512-uhmLFETqPPNyuLLbsKz6ioJ4q7AZHzD8ZVFNATNyICSZouqP2Sz0rotWQC8UNBF6VGSCs5abnKJoStA6JbCbfg==" }, - "vue-analytics": { - "version": "5.22.1", - "resolved": "https://registry.npmjs.org/vue-analytics/-/vue-analytics-5.22.1.tgz", - "integrity": "sha512-HPKQMN7gfcUqS5SxoO0VxqLRRSPkG1H1FqglsHccz6BatBatNtm/Vyy8brApktZxNCfnAkrSVDpxg3/FNDeOgQ==" - }, "vue-awesome": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/vue-awesome/-/vue-awesome-4.1.0.tgz", diff --git a/package.json b/package.json index 1e62cdb..a53d0c7 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ }, "dependencies": { "@nuxtjs/axios": "^5.12.2", - "@nuxtjs/google-analytics": "^2.4.0", "@nuxtjs/google-fonts": "^1.2.0", "@nuxtjs/pwa": "^3.0.2", "axios": "^0.21.1", From b4e8f3319bca5b7ef131e31910de4e5c4bad1f28 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 30 Jan 2023 15:04:10 +0000 Subject: [PATCH 2/3] Switch from GA to Matomo. --- components/BusinessPage.vue | 34 +++++++++++++++++++--------------- layouts/default.vue | 17 +++++++++++++++++ mixins/cabin.js | 16 ---------------- mixins/global.js | 2 +- nuxt.config.js | 4 ---- 5 files changed, 37 insertions(+), 36 deletions(-) delete mode 100644 mixins/cabin.js diff --git a/components/BusinessPage.vue b/components/BusinessPage.vue index 4009336..1e550f4 100644 --- a/components/BusinessPage.vue +++ b/components/BusinessPage.vue @@ -401,27 +401,31 @@ export default { this.busy = false // Track the search. - this.cabin( - 'search', - 'submit_' + this.region, - this.category || 'All Categories' - ) - - this.cabin( - 'search', - 'location_' + this.region, - this.location || 'No location' - ) + // this.cabin( + // 'search', + // 'submit_' + this.region, + // this.category || 'All Categories' + // ) + // + // this.cabin( + // 'search', + // 'location_' + this.region, + // this.location || 'No location' + // ) }, select(uid) { this.selected = uid // Track the select. const business = this.$store.getters['businesses/get'](uid) - const value = [business.name, business.address, business.postcode].join( - ', ' - ) - this.cabin('map', 'select_' + this.region, value) + const value = [business.address, business.postcode].join(', ') + // this.$ga.event('map', 'select_' + this.region, value) + window._paq.push([ + 'trackEvent', + 'select_' + this.region, + business.name, + value, + ]) }, showMoreInfo() { this.waitForRef('moreinfomodal', () => { diff --git a/layouts/default.vue b/layouts/default.vue index f05d045..d213801 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -135,6 +135,23 @@ export default { return ret }, }, + mounted() { + const _paq = (window._paq = window._paq || []) + /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ + _paq.push(['trackPageView']) + _paq.push(['enableLinkTracking']) + ;(function () { + const u = 'https://restarters.matomo.cloud/' + _paq.push(['setTrackerUrl', u + 'matomo.php']) + _paq.push(['setSiteId', '1']) + const d = document + const g = d.createElement('script') + const s = d.getElementsByTagName('script')[0] + g.async = true + g.src = '//cdn.matomo.cloud/restarters.matomo.cloud/matomo.js' + s.parentNode.insertBefore(g, s) + })() + }, }