Analytics I think?

This commit is contained in:
Kasper Rynning-Tønnesen
2020-01-23 11:18:34 +01:00
parent c414a8137e
commit c974354666
6 changed files with 62 additions and 9 deletions

5
package-lock.json generated
View File

@@ -10326,6 +10326,11 @@
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.11.tgz", "resolved": "https://registry.npmjs.org/vue/-/vue-2.6.11.tgz",
"integrity": "sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ==" "integrity": "sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ=="
}, },
"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-hot-reload-api": { "vue-hot-reload-api": {
"version": "2.3.4", "version": "2.3.4",
"resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz", "resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",

View File

@@ -30,6 +30,7 @@
"passport-local": "^1.0.0", "passport-local": "^1.0.0",
"passport-local-mongoose": "^6.0.1", "passport-local-mongoose": "^6.0.1",
"vue": "~2.6", "vue": "~2.6",
"vue-analytics": "^5.22.1",
"vue-router": "~3.0", "vue-router": "~3.0",
"vuex": "^3.1.1" "vuex": "^3.1.1"
}, },

View File

@@ -1,9 +1,7 @@
<template> <template>
<div class="container"> <div class="container">
<h1 class="title">Loddgenerator</h1> <h1 class="title">Loddgenerator</h1>
<p class="subtext"> <p class="subtext">Velg hvilke farger du vil ha, fyll inn antall lodd og klikk 'generer'</p>
Velg hvilke farger du vil ha, fyll inn antall lodd og klikk 'generer'
</p>
<div class="input-line"> <div class="input-line">
<label for="redCheckbox"> <label for="redCheckbox">
<input type="checkbox" id="redCheckbox" v-model="redCheckbox" /> <input type="checkbox" id="redCheckbox" v-model="redCheckbox" />
@@ -58,6 +56,7 @@
</template> </template>
<script> <script>
import { page, event } from "vue-analytics";
import Vipps from "@/ui/Vipps"; import Vipps from "@/ui/Vipps";
import Banner from "@/ui/Banner"; import Banner from "@/ui/Banner";
@@ -86,9 +85,23 @@ export default {
this.generateColors(); this.generateColors();
} }
}, },
mounted() {
if (window.location.hostname == "localhost") {
return;
}
this.track();
},
methods: { methods: {
generateColors: function(event, time) { generateColors: function(event, time) {
if (time == 5) { if (time == 5) {
if (window.location.hostname == "localhost") {
return;
}
this.$ga.event({
eventCategory: "Ballots",
eventAction: "Generate",
eventValue: JSON.stringify(this.colors)
});
return; return;
} }
if (time == undefined) { if (time == undefined) {
@@ -158,6 +171,9 @@ export default {
if (number == 4) { if (number == 4) {
return "blue"; return "blue";
} }
},
track() {
this.$ga.page("/generate");
} }
} }
}; };

View File

@@ -28,6 +28,7 @@
</template> </template>
<script> <script>
import { page, event } from "vue-analytics";
import PurchaseGraph from "@/ui/PurchaseGraph"; import PurchaseGraph from "@/ui/PurchaseGraph";
import TotalBought from "@/ui/TotalBought"; import TotalBought from "@/ui/TotalBought";
import Highscore from "@/ui/Highscore"; import Highscore from "@/ui/Highscore";
@@ -45,6 +46,17 @@ export default {
Banner, Banner,
Wines, Wines,
Vipps Vipps
},
mounted() {
if (window.location.hostname == "localhost") {
return;
}
this.track();
},
methods: {
track() {
this.$ga.page("/");
}
} }
}; };
</script> </script>

View File

@@ -3,22 +3,25 @@
<h3>Topp viner</h3> <h3>Topp viner</h3>
<ol> <ol>
<li v-for="wine in wines"> <li v-for="wine in wines">
<span v-if="wine.vivinoLink == '' || wine.vivinoLink == null" <span v-if="wine.vivinoLink == '' || wine.vivinoLink == null">
>{{ wine.name }} - sett {{ wine.occurences }} ganger, {{ wine.name }} - sett {{ wine.occurences }} ganger,
{{ wine.rating }} i rating</span {{ wine.rating }} i rating
> </span>
<a <a
:href="wine.vivinoLink" :href="wine.vivinoLink"
v-if="wine.vivinoLink != '' && wine.vivinoLink != null" v-if="wine.vivinoLink != '' && wine.vivinoLink != null"
>{{ wine.name }} - sett {{ wine.occurences }} ganger, @click="wineClick(wine)"
{{ wine.rating }} i rating</a
> >
{{ wine.name }} - sett {{ wine.occurences }} ganger,
{{ wine.rating }} i rating
</a>
</li> </li>
</ol> </ol>
</div> </div>
</template> </template>
<script> <script>
import { event } from "vue-analytics";
export default { export default {
data() { data() {
return { wines: [] }; return { wines: [] };
@@ -32,6 +35,18 @@ export default {
.filter(wine => wine.name != null && wine.name != "") .filter(wine => wine.name != null && wine.name != "")
.sort((a, b) => (a.occurences > b.occurences ? -1 : 1)); .sort((a, b) => (a.occurences > b.occurences ? -1 : 1));
this.wines = response; this.wines = response;
},
methods: {
wineClick: function(wine) {
if (window.location.hostname == "localhost") {
return;
}
this.$ga.event({
eventCategory: "Wines",
eventAction: "click",
eventValue: `${wine.name} - ${wine.vivinoLink}`
});
}
} }
}; };
</script> </script>

View File

@@ -2,8 +2,12 @@ import Vue from "vue";
import VueRouter from "vue-router"; import VueRouter from "vue-router";
import { routes } from "@/routes/vinlottisRouter"; import { routes } from "@/routes/vinlottisRouter";
import Vinlottis from "@/Vinlottis"; import Vinlottis from "@/Vinlottis";
import VueAnalytics from "vue-analytics";
Vue.use(VueRouter); Vue.use(VueRouter);
Vue.use(VueAnalytics, {
id: "UA-156846886-1"
});
const router = new VueRouter({ const router = new VueRouter({
routes: routes routes: routes