@@ -7,22 +7,55 @@ useHead({
77
88// composables return the underlying api as a proxy object and the script state
99const { status, proxy } = useScriptMatomoAnalytics ({
10- cloudId : ' nuxt.matomo.cloud' ,
10+ matomoUrl : ' https:// nuxt.matomo.cloud/ ' ,
1111 siteId: ' 1' ,
1212 scriptOptions: {
1313 trigger: ' onNuxtReady' ,
1414 },
1515})
1616
17- // Use proxy to track page view
17+ // Test the issue: Use proxy to track events and goals
18+ // Note: setTrackerUrl and setSiteId are automatically set by the registry based on matomoUrl and siteId options
1819proxy ._paq .push ([' trackPageView' ])
20+
21+ // Test custom events and goals that were not working in the original issue
22+ function trackCustomEvent() {
23+ proxy ._paq .push ([' trackEvent' , ' Test' , ' Button Click' , ' Proxy Test' ])
24+ }
25+
26+ function trackGoal() {
27+ proxy ._paq .push ([' trackGoal' , 1 ])
28+ }
29+
30+ function testDirectPaq() {
31+ // Test direct window._paq usage for comparison
32+ if (window ._paq ) {
33+ window ._paq .push ([' trackEvent' , ' Test' , ' Button Click' , ' Direct Test' ])
34+ }
35+ }
1936 </script >
2037
2138<template >
2239 <div >
40+ <h1 >Matomo Analytics Test</h1 >
2341 <ClientOnly >
2442 <div >
25- status: {{ status }}
43+ <p >Script status: {{ status }}</p >
44+
45+ <div style =" margin : 20px 0 ;" >
46+ <UButton @click =" trackCustomEvent" style =" margin-right : 10px ; padding : 10px ;" >
47+ Track Custom Event (proxy._paq)
48+ </UButton >
49+ <UButton @click =" trackGoal" style =" padding : 10px ;" >
50+ Track Goal (proxy._paq)
51+ </UButton >
52+ </div >
53+
54+ <div style =" margin : 20px 0 ;" >
55+ <UButton @click =" testDirectPaq" style =" margin-right : 10px ; padding : 10px ;" >
56+ Track Event (direct window._paq)
57+ </UButton >
58+ </div >
2659 </div >
2760 </ClientOnly >
2861 </div >
0 commit comments