Skip to content

Commit f0b2b64

Browse files
authored
chore: integrate Google Analytics 4 for documentation site (#22)
- Add GA4 tracking code (G-SJ0LD5F754) to Starlight configuration - Implement gtag.js script injection in head section - Enable analytics tracking for all documentation pages on GitHub Pages
1 parent 6a497d3 commit f0b2b64

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/astro.config.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ export default defineConfig({
1313
logo: {
1414
src: './src/assets/odin-logo.png',
1515
},
16+
head: [
17+
{
18+
tag: 'script',
19+
attrs: {
20+
src: 'https://www.googletagmanager.com/gtag/js?id=G-SJ0LD5F754',
21+
async: true,
22+
},
23+
},
24+
{
25+
tag: 'script',
26+
content: `
27+
window.dataLayer = window.dataLayer || [];
28+
function gtag(){dataLayer.push(arguments);}
29+
gtag('js', new Date());
30+
gtag('config', 'G-SJ0LD5F754');
31+
`,
32+
},
33+
],
1634
social: [
1735
{
1836
icon: 'github',

0 commit comments

Comments
 (0)