From 25fa3942ac6034141ef1dc6c1b43a9dc165343b6 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Wed, 18 Jan 2023 14:00:57 +0000 Subject: [PATCH] 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",