Skip to content

Commit 675ea12

Browse files
authored
feat(docs): add Google Analytics tracking to VitePress documentation (#216)
- Integrate vitepress-plugin-google-analytics for clean SPA navigation handling - Support VITE_GA_ID env var override, default to G-RY1XJ7LR5F Closes #214
1 parent f285d52 commit 675ea12

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

docs/.vitepress/theme/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { h } from "vue";
22
import DefaultTheme from "vitepress/theme";
33
import type { Theme } from "vitepress";
4+
import googleAnalytics from "vitepress-plugin-google-analytics";
45
import "./style.css";
56
import BugReportWidget from "./components/BugReportWidget.vue";
67

@@ -11,4 +12,9 @@ export default {
1112
"layout-bottom": () => h(BugReportWidget),
1213
});
1314
},
15+
enhanceApp({ app }) {
16+
googleAnalytics({
17+
id: import.meta.env.VITE_GA_ID || "G-RY1XJ7LR5F",
18+
});
19+
},
1420
} satisfies Theme;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
"ts-jest": "^29.4.6",
113113
"ts-node": "^10.9.2",
114114
"typescript": "^5.9.3",
115-
"vitepress": "^1.6.4"
115+
"vitepress": "^1.6.4",
116+
"vitepress-plugin-google-analytics": "^1.0.2"
116117
}
117118
}

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,7 @@ __metadata:
26572657
typescript: "npm:^5.9.3"
26582658
undici: "npm:^7.19.1"
26592659
vitepress: "npm:^1.6.4"
2660+
vitepress-plugin-google-analytics: "npm:^1.0.2"
26602661
yaml: "npm:^2.8.2"
26612662
zod: "npm:^4.3.6"
26622663
bin:
@@ -11049,6 +11050,13 @@ __metadata:
1104911050
languageName: node
1105011051
linkType: hard
1105111052

11053+
"vitepress-plugin-google-analytics@npm:^1.0.2":
11054+
version: 1.0.2
11055+
resolution: "vitepress-plugin-google-analytics@npm:1.0.2"
11056+
checksum: 10c0/17b09ff91cf7f3bdd43373386f37315e88094576834dd5256071c8f357f43b23a0cb3a059f014cabccd80aea5f685c3947451f81b79d8f82add7e263ed80ccde
11057+
languageName: node
11058+
linkType: hard
11059+
1105211060
"vitepress@npm:^1.6.4":
1105311061
version: 1.6.4
1105411062
resolution: "vitepress@npm:1.6.4"

0 commit comments

Comments
 (0)