-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
53 lines (46 loc) · 1.29 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<script setup lang="ts">
const config = useAppConfig()
const route = useRoute()
useHead({
meta: [{ property: 'og:title', content: `PURISTA Voyage - ${route.meta.title}` }],
titleTemplate: (titleChunk) => {
return titleChunk ? `${titleChunk} - PURISTA Voyage` : config.title
},
})
const { cookiesEnabledIds, isConsentGiven } = useCookieControl('google-analytics')
onMounted(() => {
if (isConsentGiven.value && cookiesEnabledIds.value?.includes('google-analytics')) {
const { gtag, initialize } = useGtag()
initialize()
gtag('consent', 'update', {
ad_user_data: 'granted',
ad_personalization: 'granted',
ad_storage: 'granted',
analytics_storage: 'granted',
})
}
})
// example: react to a cookie being accepted
watch(
() => cookiesEnabledIds.value,
(current, previous) => {
if (!previous?.includes('google-analytics') && current?.includes('google-analytics')) {
const { gtag, initialize } = useGtag()
initialize()
gtag('consent', 'update', {
ad_user_data: 'granted',
ad_personalization: 'granted',
ad_storage: 'granted',
analytics_storage: 'granted',
})
}
},
{ deep: true }
)
</script>
<template>
<CookieControl locale="en" />
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>