Skip to content

Commit 5afdfbd

Browse files
committed
#3414 webpage: start with mtomo integration
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent 2bc072f commit 5afdfbd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

webpage/src/.vuepress/client.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,36 @@ export default defineClientConfig({
6464
app.component("BlogDate", BlogDate);
6565
app.component("BlogIndex", BlogIndex);
6666
app.component("ProfileCard", ProfileCard);
67+
68+
// Initialize Matomo Analytics (client-side only)
69+
if (typeof window !== "undefined") {
70+
// Matomo tracking code
71+
window._paq = window._paq || [];
72+
window._paq.push(["trackPageView"]);
73+
window._paq.push(["enableLinkTracking"]);
74+
75+
(function () {
76+
var u = "https://p.bekerle.com/";
77+
window._paq.push(["setTrackerUrl", u + "matomo.php"]);
78+
window._paq.push(["setSiteId", "7"]);
79+
80+
var d = document;
81+
var g = d.createElement("script");
82+
var s = d.getElementsByTagName("script")[0];
83+
g.async = true;
84+
g.src = u + "matomo.js";
85+
s.parentNode.insertBefore(g, s);
86+
})();
87+
88+
// Track page changes on route navigation
89+
router.afterEach((to) => {
90+
if (window._paq) {
91+
window._paq.push(["setCustomUrl", window.location.href]);
92+
window._paq.push(["setDocumentTitle", document.title]);
93+
window._paq.push(["trackPageView"]);
94+
}
95+
});
96+
}
6797
},
6898
setup() {},
6999
rootComponents: [],

0 commit comments

Comments
 (0)