Skip to content

Commit 10da0a8

Browse files
committed
Initial Google Analytics setup
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent 7a2d46b commit 10da0a8

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"clipboard": "^2.0.4",
3030
"core-js": "^3.6.1",
3131
"vue": "^2.6.10",
32+
"vue-analytics": "^5.22.1",
3233
"vue-i18n": "^8.15.3"
3334
},
3435
"devDependencies": {

src/App.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export default {
4646
Header,
4747
Footer,
4848
Locale
49+
},
50+
created: function() {
51+
// send home to google analytics
52+
this.$ga.page('/')
4953
}
5054
}</script>
5155
<style lang="scss">

src/components/SelectedLicenseDropdown.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ export default {
5151
},
5252
set(currentLicense) {
5353
const fullLicenseName = this.fullLicenseName(currentLicense)
54+
this.$ga.event({
55+
eventCategory: 'licenseDropdown',
56+
eventAction: 'clicked',
57+
eventLabel: 'License selected from the dropdown'
58+
})
5459
this.$emit('input', { ...this.$props.value, fullName: fullLicenseName, shortName: currentLicense })
5560
}
5661
}

src/components/Stepper.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,17 @@ export default {
139139
updateLicense(itemId) {
140140
const attrs = { ...this.licenseAttributes }
141141
attrs[itemId] = !attrs[itemId]
142-
this.$emit('input', {
142+
const licenseData = {
143143
shortName: this.shortLicenseName(attrs),
144144
fullName: this.fullLicenseName(attrs),
145145
attributionDetails: this.$props.value.attributionDetails
146+
}
147+
this.$ga.event({
148+
eventCategory: 'stepper',
149+
eventAction: 'clicked',
150+
eventLabel: licenseData.shortName
146151
})
152+
this.$emit('input', licenseData)
147153
},
148154
shortLicenseName(attr) {
149155
if (!attr.BY) { return 'CC0 1.0' }

src/main.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import Vue from 'vue'
2-
import App from './App.vue'
32
import Buefy from 'buefy'
43
import i18n from './i18n'
4+
import VueAnalytics from 'vue-analytics'
5+
import App from './App.vue'
56
import { library } from '@fortawesome/fontawesome-svg-core'
67
// internal icons
78
import {
@@ -21,6 +22,14 @@ Vue.use(Buefy, {
2122
defaultIconComponent: 'vue-fontawesome',
2223
defaultIconPack: 'fas'
2324
})
25+
26+
Vue.use(VueAnalytics, {
27+
id: 'UA-XXX-X',
28+
autoTracking: {
29+
screenview: true
30+
}
31+
})
32+
2433
Vue.use(LicenseUtilities)
2534

2635
new Vue({

0 commit comments

Comments
 (0)