Skip to content

Commit

Permalink
feat: add tracking for route changes
Browse files Browse the repository at this point in the history
  • Loading branch information
silvester-pari committed Mar 5, 2025
1 parent e0ba1ff commit b8bdb5b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
<script setup>
import { onMounted } from "vue";
import { onMounted, watch } from "vue";
import { useData, useRouter } from "vitepress";
import DefaultTheme from "vitepress/theme";
const { Layout } = DefaultTheme;
const { site, theme, frontmatter } = useData();
const router = useRouter();
if (typeof window !== 'undefined' && window._paq) {
watch(() => router.route.data.relativePath, (path) => {
window._paq.push(["setCustomUrl", path.replace(".md", "")]);
window._paq.push([
"setDocumentTitle",
document.domain + "/" + document.title,
]);
window._paq.push(["trackPageView"]);
window._paq.push(["enableLinkTracking"]);
}, { immediate: true });
}
onMounted(async () => {
setTimeout(() => {
Expand Down

0 comments on commit b8bdb5b

Please sign in to comment.