File tree Expand file tree Collapse file tree 13 files changed +206
-223
lines changed Expand file tree Collapse file tree 13 files changed +206
-223
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,6 @@ More coming soon!
87
87
[ // ] : # ( TODO | `plausible-analytics` | Plausible Analytics | `usePlausibleAnalytics` | )
88
88
[ // ] : # ( TODO | `simple-analytics` | Simple Analytics | `useSimpleAnalytics` | )
89
89
[ // ] : # ( TODO | `umami-analytics` | Umami Analytics | `useUmamiAnalytics` | )
90
- [ // ] : # ( TODO | `cloudflare-web-analytics` | Cloudflare Web Analytics | `useCloudflareWebAnalytics` | )
91
90
[ // ] : # ( TODO | `matomo` | Matomo | `useMatomo` | )
92
91
93
92
### Loading Scripts Globally
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ onDevtoolsClientConnected(async (client) => {
47
47
<div >{{ script.key }}</div >
48
48
</a >
49
49
<div class =" opacity-70" >
50
- {{ script.$script.status }}
50
+ {{ script.$script.status.value }}
51
51
</div >
52
52
<div v-if =" scriptSizes[script.key]" >
53
53
{{ scriptSizes[script.key] }}
Original file line number Diff line number Diff line change 47
47
"build" : {
48
48
"externals" : [
49
49
" @unhead/vue" ,
50
- " @unhead/schema"
50
+ " @unhead/schema" ,
51
+ " @unhead/vue" ,
52
+ " #nuxt-scripts"
51
53
]
52
54
},
53
55
"dependencies" : {
54
56
"@nuxt/devtools-kit" : " ^1.1.5" ,
55
57
"@nuxt/devtools-ui-kit" : " ^1.1.5" ,
56
58
"@nuxt/kit" : " ^3.11.1" ,
59
+ "@unhead/vue" : " ^1.9.3" ,
57
60
"consola" : " ^3.2.3" ,
58
61
"defu" : " ^6.1.4" ,
59
62
"estree-walker" : " ^3.0.3" ,
Original file line number Diff line number Diff line change 1
- <script lang="ts" setup>
2
- import { ref , useAnalyticsPageEvent , useScript } from ' #imports'
3
- import { scriptConsent } from ' ~/composables/consent'
4
-
5
- interface GenericTrackingScript {
6
- track: (title : string , path : string ) => void
7
- }
8
-
9
- const { track } = useScript <GenericTrackingScript >(' https://example.com/script.js?nuxt-scripts=inline' , {
10
- trigger: scriptConsent ,
11
- })
12
- useAnalyticsPageEvent ((payload ) => {
13
- track (payload )
14
- })
15
-
16
- const showCookieBanner = ref (true )
17
-
18
- function acceptCookies() {
19
- scriptConsent .accept ()
20
- showCookieBanner .value = false
21
- }
22
- </script >
23
-
24
1
<template >
25
2
<div class =" flex flex-col min-h-screen" >
26
3
<header class =" sticky top-0 z-50 w-full backdrop-blur flex-none border-b border-gray-900/10 dark:border-gray-50/[0.06] bg-white/75 dark:bg-gray-900/75" >
@@ -47,18 +24,5 @@ function acceptCookies() {
47
24
</div >
48
25
</UContainer >
49
26
</main >
50
- <div v-if =" showCookieBanner" id =" cookie-consent" class =" p-5 bg-blue-900" >
51
- <div class =" font-bold mb-2" >
52
- Do you accept cookies?
53
- </div >
54
- <div class =" flex items-center gap-4" >
55
- <UButton @click =" acceptCookies" >
56
- Yes
57
- </UButton >
58
- <UButton @click =" showCookieBanner = false" >
59
- No
60
- </UButton >
61
- </div >
62
- </div >
63
27
</div >
64
28
</template >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -6,13 +6,6 @@ export default defineNuxtConfig({
6
6
] ,
7
7
devtools : { enabled : true } ,
8
8
scripts : {
9
- globals : [
10
- 'https://cdn.jsdelivr.net/npm/[email protected] /dist/vue.global.prod.js' ,
11
- ] ,
12
- overrides : {
13
- 'cloudflare-turnstile' : {
14
- assetStrategy : 'bundle' ,
15
- } ,
16
- } ,
9
+ // TODO globals / register / overrides
17
10
} ,
18
11
} )
Original file line number Diff line number Diff line change
1
+ <script lang="ts" setup>
2
+ import { ref } from ' vue'
3
+ import { createScriptConsentTrigger , useScript } from ' #imports'
4
+
5
+ const showCookieBanner = ref (true )
6
+ const scriptConsent = createScriptConsentTrigger ()
7
+ function acceptCookies() {
8
+ scriptConsent .accept ()
9
+ showCookieBanner .value = false
10
+ }
11
+ useScript (' https://www.googletagmanager.com/gtag/js?id=GTM-5ZQZJZ' , {
12
+ trigger: scriptConsent ,
13
+ assetStrategy: ' bundle' ,
14
+ })
15
+ </script >
16
+
17
+ <template >
18
+ <div v-if =" showCookieBanner" id =" cookie-consent" class =" p-5 bg-blue-900" >
19
+ <div class =" font-bold mb-2" >
20
+ Do you accept cookies?
21
+ </div >
22
+ <div class =" flex items-center gap-4" >
23
+ <UButton @click =" acceptCookies" >
24
+ Yes
25
+ </UButton >
26
+ <UButton @click =" showCookieBanner = false" >
27
+ No
28
+ </UButton >
29
+ </div >
30
+ </div >
31
+ </template >
File renamed without changes.
Original file line number Diff line number Diff line change @@ -31,6 +31,17 @@ const thirdParties = [
31
31
path: ' /third-parties/segment' ,
32
32
},
33
33
]
34
+
35
+ const features = [
36
+ {
37
+ name: ' Cookie Consent' ,
38
+ path: ' /features/cookie-consent' ,
39
+ },
40
+ {
41
+ name: ' Trigger: On Nuxt Ready' ,
42
+ path: ' /features/on-nuxt-ready' ,
43
+ },
44
+ ]
34
45
</script >
35
46
36
47
<template >
@@ -54,6 +65,24 @@ const thirdParties = [
54
65
</div >
55
66
</div >
56
67
</div >
68
+ <div >
69
+ <h2 class =" font-bold mb-5 text-xl flex items-center" >
70
+ <Icon
71
+ name =" carbon:intent-request-create"
72
+ class =" opacity-70 mr-2"
73
+ />Features
74
+ </h2 >
75
+ <div class =" grid grid-cols-3 gap-5" >
76
+ <div v-for =" (s, key) in features" :key >
77
+ <ULink
78
+ :to =" s.path"
79
+ class =" underline"
80
+ >
81
+ {{ s.name }}
82
+ </ULink >
83
+ </div >
84
+ </div >
85
+ </div >
57
86
</div >
58
87
</div >
59
88
</template >
Original file line number Diff line number Diff line change @@ -6,38 +6,27 @@ useHead({
6
6
})
7
7
8
8
// composables return the underlying api as a proxy object and a $script with the script state
9
- const { $script, trackPageview, trackGoal } = useScriptFathomAnalytics ({
9
+ const { $script, trackPageview, trackEvent } = useScriptFathomAnalytics ({
10
10
site: ' BRDEJWKJ' ,
11
- // load after 3 seconds
12
- trigger: new Promise <void >((resolve ) => {
13
- setTimeout (() => {
14
- resolve ()
15
- }, 2000 )
16
- }),
17
11
})
18
12
// this will be triggered once the script is ready async
19
13
trackPageview ({ url: ' /fathom' })
20
- // we can manually wait for the script to be ready (TODO error handling)
21
- $script .then (() => {
22
- // eslint-disable-next-line no-console
23
- console .log (' fathom is ready' )
24
- })
25
- //
14
+
26
15
const clicks = ref (0 )
27
- async function trackEvent () {
16
+ async function clickHandler () {
28
17
clicks .value ++
29
- trackGoal ( ' button ' , clicks .value )
18
+ trackEvent ( ' ClickedButton ' , { _value: clicks .value } )
30
19
}
31
20
</script >
32
21
33
22
<template >
34
23
<div >
35
- <UButton @click =" trackEvent " >
24
+ <UButton @click =" clickHandler " >
36
25
important conversion {{ clicks }}
37
26
</UButton >
38
27
<ClientOnly >
39
28
<div >
40
- status: {{ $script.status }}
29
+ status: {{ $script.status.value }}
41
30
</div >
42
31
</ClientOnly >
43
32
</div >
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ const { $script } = useScriptSegment({ writeKey: 'KBXOGxgqMFjm2mxtJDJg0iDn5AnGYb
13
13
<div >
14
14
<ClientOnly >
15
15
<div >
16
- status: {{ $script.status }}
16
+ status: {{ $script.status.value }}
17
17
</div >
18
18
</ClientOnly >
19
19
</div >
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments