From ab897b8a81e024ba64dc2478c425c602cdf20212 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 8 May 2026 20:02:45 +0200 Subject: [PATCH] Wire Google Analytics 4 (G-V8QWB45G6X) alongside Umami MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds gtag.js to the production head so Search Console can cross-reference GA traffic. Same gating as Umami — production builds only, never injected on dev. Three head entries: 1. Umami (kept) — self-hosted, DNT-aware, GDPR-light 2. Google's gtag loader (async) 3. Inline init: window.dataLayer + gtag('config', 'G-V8QWB45G6X') Both analytics run side-by-side; pick one or both in the GA dashboard. A GDPR consent banner is not added — configure IP anonymisation + consent mode v2 in the GA property settings if you intend to serve EU visitors without explicit cookie acceptance. Co-Authored-By: Claude Opus 4.7 (1M context) --- docs/astro.config.mjs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 272692c..f48632d 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -128,9 +128,12 @@ export default defineConfig({ title: 'Nibiru', description: 'A modular MMVC PHP framework for rapid prototyping. Born among the old gods, built for modern builders.', - // Umami analytics — self-hosted, cookie-free, honours Do-Not-Track. - // No GDPR consent banner needed because no PII or cross-site state - // is captured. The script is only injected on production builds. + // Analytics — production-only. + // 1. Umami (self-hosted) — cookie-free, honours Do-Not-Track, + // no PII captured, no GDPR banner required. + // 2. Google Analytics 4 (gtag.js) — added for Search Console + // cross-linking + audience reach. Subject to GDPR; configure + // consent / IP-anonymisation in the GA property settings. head: import.meta.env.PROD ? [ { @@ -143,6 +146,21 @@ export default defineConfig({ 'data-exclude-search': 'true', }, }, + { + tag: 'script', + attrs: { + async: true, + src: 'https://www.googletagmanager.com/gtag/js?id=G-V8QWB45G6X', + }, + }, + { + tag: 'script', + content: + "window.dataLayer = window.dataLayer || [];\n" + + "function gtag(){dataLayer.push(arguments);}\n" + + "gtag('js', new Date());\n" + + "gtag('config', 'G-V8QWB45G6X');", + }, ] : [], logo: {