From 5a549f6e137880cd082776c875fbc2c36a9f80d7 Mon Sep 17 00:00:00 2001 From: Juan Cruz Fortunatti Date: Sun, 13 Sep 2026 20:47:06 +0200 Subject: [PATCH] fix: add site analytics tracking --- website/astro.config.mjs | 18 +++++++++++++++++- website/site.config.mjs | 14 ++++++++++++++ website/src/components/GoogleAnalytics.astro | 9 +++++++++ website/src/pages/index.astro | 2 ++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 website/site.config.mjs create mode 100644 website/src/components/GoogleAnalytics.astro diff --git a/website/astro.config.mjs b/website/astro.config.mjs index f27d9a4..4902779 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -2,14 +2,30 @@ import { defineConfig } from 'astro/config'; import starlight from '@astrojs/starlight'; import sitemap from '@astrojs/sitemap'; +import { googleAnalyticsInlineScript, googleAnalyticsScriptSrc } from './site.config.mjs'; export default defineConfig({ site: 'https://simfile.org', integrations: [ - sitemap(), + sitemap({ + filter: (page) => !page.endsWith('/city-lab/'), + }), starlight({ title: 'Simfile', description: 'Deterministic simulation worlds for agentic organizations.', + head: [ + { + tag: 'script', + attrs: { + async: true, + src: googleAnalyticsScriptSrc(), + }, + }, + { + tag: 'script', + content: googleAnalyticsInlineScript(), + }, + ], components: { Header: './src/components/DocsHeader.astro', ThemeSelect: './src/components/EmptyThemeSelect.astro', diff --git a/website/site.config.mjs b/website/site.config.mjs new file mode 100644 index 0000000..5f08e17 --- /dev/null +++ b/website/site.config.mjs @@ -0,0 +1,14 @@ +export const googleTagId = 'G-LZQ6G6JGJE'; + +export function googleAnalyticsScriptSrc() { + return `https://www.googletagmanager.com/gtag/js?id=${googleTagId}`; +} + +export function googleAnalyticsInlineScript() { + return [ + 'window.dataLayer = window.dataLayer || [];', + 'function gtag(){dataLayer.push(arguments);}', + "gtag('js', new Date());", + `gtag('config', ${JSON.stringify(googleTagId)});`, + ].join('\n'); +} diff --git a/website/src/components/GoogleAnalytics.astro b/website/src/components/GoogleAnalytics.astro new file mode 100644 index 0000000..2c99afc --- /dev/null +++ b/website/src/components/GoogleAnalytics.astro @@ -0,0 +1,9 @@ +--- +import { googleAnalyticsInlineScript, googleAnalyticsScriptSrc } from '../../site.config.mjs'; + +const scriptSrc = googleAnalyticsScriptSrc(); +const inlineScript = googleAnalyticsInlineScript(); +--- + + + diff --git a/website/src/pages/index.astro b/website/src/pages/index.astro index b7cb4b0..773a779 100644 --- a/website/src/pages/index.astro +++ b/website/src/pages/index.astro @@ -1,5 +1,6 @@ --- import GlyphCity from '../components/GlyphCity.astro'; +import GoogleAnalytics from '../components/GoogleAnalytics.astro'; import LandingWorldSection from '../components/LandingWorldSection.astro'; import SiteHeader from '../components/SiteHeader.astro'; import '../styles/landing.css'; @@ -30,6 +31,7 @@ import '../styles/landing.css'; +