Skip to content

Commit

Permalink
feat: migrate to GTM
Browse files Browse the repository at this point in the history
  • Loading branch information
robb-j committed Oct 27, 2023
1 parent 4a37ca3 commit bf56f55
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 38 deletions.
34 changes: 21 additions & 13 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,28 @@
>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
<!-- Google tag (gtag.js) -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-HXLCGDQJZB"
></script>
<script>
window.dataLayer = window.dataLayer || []
function gtag() {
dataLayer.push(arguments)
}
gtag('js', new Date())

gtag('config', 'G-HXLCGDQJZB')
;(function (w, d, s, l, i) {
w[l] = w[l] || []
w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' })
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : ''
j.async = true
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl
f.parentNode.insertBefore(j, f)
})(window, document, 'script', 'dataLayer', 'GTM-PB5FRTL')
</script>
<!-- End Google Tag Manager -->
<!-- Google Tag Manager (noscript) -->
<noscript
><iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-PB5FRTL"
height="0"
width="0"
style="display: none; visibility: hidden"
></iframe
></noscript>
<!-- End Google Tag Manager (noscript) -->
</body>
</html>
25 changes: 0 additions & 25 deletions client/src/plugins/metrics-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { MetricsEvent } from '@openlab/deconf-ui-toolkit'
import _Vue from 'vue'
import { SocketIoPlugin } from './socketio-plugin'

import VueGtagPlugin, { VueGtag, PluginOptions as GtagOptions } from 'vue-gtag'
import { env } from './env-plugin'
import router from '@/router/module'

export class MetricsPlugin {
static shared: MetricsPlugin | null = null

Expand All @@ -23,20 +19,6 @@ export class MetricsPlugin {
info: info,
})
}

const options: GtagOptions = {
enabled: Boolean(env.GA_TOKEN),
config: {
id: env.GA_TOKEN as string,
params: {
anonymize_ip: true,
allow_ad_personalization_signals: false,
allow_google_signals: false,
},
},
}

Vue.use(VueGtagPlugin, options, router)
}

track(metric: MetricsEvent): void {
Expand All @@ -46,13 +28,6 @@ export class MetricsPlugin {
metric.eventName,
metric.payload
)

const gtag: VueGtag = _Vue.prototype.$gtag
if (gtag && metric.eventName !== 'general/pageView') {
gtag.event('deconf', {
event_category: metric.eventName,
})
}
}

error(error: unknown): void {
Expand Down

0 comments on commit bf56f55

Please sign in to comment.