From ad1118dd04d4bee6870f0d2f43ed975038c15d85 Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 5 May 2020 19:54:58 +0300 Subject: [PATCH] add owa tracking --- app/nuxt.config.js | 3 ++- app/plugins/owa.js | 26 ++++++++++++++++++++++++++ docker-compose.yml | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 app/plugins/owa.js diff --git a/app/nuxt.config.js b/app/nuxt.config.js index 3644f02..445eb1e 100644 --- a/app/nuxt.config.js +++ b/app/nuxt.config.js @@ -68,7 +68,8 @@ module.exports = { ** Plugins to load before mounting the App */ plugins: [ - { src: '~/plugins/Vuelidate' } + { src: '~/plugins/Vuelidate' }, + { src: '~/plugins/owa.js', mode: 'client' } ], /* diff --git a/app/plugins/owa.js b/app/plugins/owa.js new file mode 100644 index 0000000..e7d0b3b --- /dev/null +++ b/app/plugins/owa.js @@ -0,0 +1,26 @@ +/* eslint-disable */ + +export default ({ app }) => { + /* + * ** Only run on client-side and only in production mode + * */ + if (process.env.NODE_ENV !== 'production') return + + var owa_baseUrl = 'https://owa.isnet.uk/'; + var owa_cmds = owa_cmds || []; + owa_cmds.push(['setSiteId', '0c3a9f11563be70da80f493a590b46d1']); + + (function() { + var _owa = document.createElement('script'); _owa.type = 'text/javascript'; _owa.async = true; + owa_baseUrl = ('https:' == document.location.protocol ? window.owa_baseSecUrl || owa_baseUrl.replace(/http:/, 'https:') : owa_baseUrl ); + _owa.src = owa_baseUrl + 'modules/base/js/owa.tracker-combined-min.js'; + var _owa_s = document.getElementsByTagName('script')[0]; _owa_s.parentNode.insertBefore(_owa, _owa_s); + }()); + /* + * ** Every time the route changes (fired on initialization too) + * */ + app.router.afterEach((to, from) => { + owa_cmds.push(['trackPageView']); + owa_cmds.push(['trackClicks']); + }) +} diff --git a/docker-compose.yml b/docker-compose.yml index 329931e..29afa4c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: nuxt: build: ./app/ container_name: marcleopold-rayelliott.dev - restart: always + restart: unless-stopped ports: - ${URL_INTERNAL}:3013:3013 environment: