@@ -4,15 +4,19 @@ import * as components from 'vuetify/components'
44import * as directives from 'vuetify/directives'
55import 'vuetify/styles'
66
7+ // Matomo type declaration
8+ declare global {
9+ interface Window {
10+ _paq : any [ ]
11+ }
12+ }
13+
714// Import custom components
815import Poll from './components/Poll.vue'
916import BlogDate from './components/BlogDate.vue'
1017import BlogIndex from './components/BlogIndex.vue'
1118import ProfileCard from './components/ProfileCard.vue'
1219
13- // Import Matomo analytics (replaces vuepress-plugin-matomo)
14- import { initMatomo } from './utils/matomo.js'
15-
1620export default defineClientConfig ( {
1721 enhance ( { app, router, siteData } ) {
1822 // Create Vuetify instance
@@ -34,7 +38,43 @@ export default defineClientConfig({
3438 app . component ( 'ProfileCard' , ProfileCard )
3539
3640 // Initialize Matomo Analytics (replaces vuepress-plugin-matomo)
37- initMatomo ( router )
41+ // Only run in browser environment
42+ if ( typeof window !== 'undefined' ) {
43+ // Configuration
44+ const matomoConfig = {
45+ siteId : 7 ,
46+ trackerUrl : 'https://p.bekerle.com/' ,
47+ trackerJsFile : 'matomo.js' ,
48+ }
49+
50+ // Initialize Matomo
51+ window . _paq = window . _paq || [ ]
52+ window . _paq . push ( [ 'trackPageView' ] )
53+ window . _paq . push ( [ 'enableLinkTracking' ] )
54+
55+ // Load Matomo script
56+ ; ( function ( ) {
57+ const u = matomoConfig . trackerUrl
58+ window . _paq . push ( [ 'setTrackerUrl' , u + 'matomo.php' ] )
59+ window . _paq . push ( [ 'setSiteId' , matomoConfig . siteId . toString ( ) ] )
60+
61+ const d = document
62+ const g = d . createElement ( 'script' )
63+ const s = d . getElementsByTagName ( 'script' ) [ 0 ]
64+ g . async = true
65+ g . src = u + matomoConfig . trackerJsFile
66+ s . parentNode . insertBefore ( g , s )
67+ } ) ( )
68+
69+ // Track page changes on route navigation (SPA support)
70+ router . afterEach ( ( to ) => {
71+ if ( window . _paq ) {
72+ window . _paq . push ( [ 'setCustomUrl' , window . location . href ] )
73+ window . _paq . push ( [ 'setDocumentTitle' , document . title ] )
74+ window . _paq . push ( [ 'trackPageView' ] )
75+ }
76+ } )
77+ }
3878 } ,
3979 setup ( ) { } ,
4080 rootComponents : [ ] ,
0 commit comments