Events not working if enabling GA in component
aleksejssaburovs92 opened this issue · 1 comments
aleksejssaburovs92 commented
Events are not sending, if i enable GA in mounted hook on second load. But it works on first page load, when i click button Accept
<template>
<div v-if="isOpen" class="cookie">
<div class="container">
<div class="cookie__wrap">
<div class="cookie__content">
This site uses cookies, as explained in our
<nuxt-link :to="localePath({ name: 'privacy-policy' })"
>cookie policy</nuxt-link
>.<br />
If you agree to our use of cookies, please accept this message and
continue to use this site
</div>
<button class="btn--secondary" type="button" @click="accept">
Accept
</button>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'CookieMessage',
data() {
return {
isOpen: false,
}
},
mounted() {
if (!this.getGDPR() === true) {
this.isOpen = true
} else {
this.$gtm.init()
this.$ga.enable()
}
},
methods: {
getGDPR() {
if (process.browser) {
return localStorage.getItem('GDPR:accepted', true)
}
},
accept() {
if (process.browser) {
this.isOpen = false
localStorage.setItem('GDPR:accepted', true)
this.$gtm.init()
this.$ga.enable()
}
},
},
}
</script>
ricardogobbosouza commented
See #94