From 1fd35322ea4d56dea8f1959edf4b0c0ecca27e8c Mon Sep 17 00:00:00 2001 From: Val Neekman Date: Fri, 5 Sep 2025 19:04:38 -0400 Subject: [PATCH] feat: make Google Analytics configurable via environment variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Google Analytics only loads if NEXT_PUBLIC_GA_MEASUREMENT_ID is set - Added .env.example with optional GA configuration - Keeps tracking ID private and out of open source code - No analytics tracking without explicit configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .env.example | 4 ++-- src/pages/_document.tsx | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index c539b6a..dded42e 100644 --- a/.env.example +++ b/.env.example @@ -8,5 +8,5 @@ NEXT_PUBLIC_APP_URL=https://btc.eh-aye.net # API endpoints (if needed) # NEXT_PUBLIC_API_URL=https://api.eh-aye.net -# Analytics (optional) -# NEXT_PUBLIC_GA_ID=G-XXXXXXXXXX \ No newline at end of file +# Google Analytics (optional) +# NEXT_PUBLIC_GA_MEASUREMENT_ID=G-XXXXXXXXXX \ No newline at end of file diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index 17a4208..46b75d2 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -1,9 +1,31 @@ import { Head, Html, Main, NextScript } from "next/document"; export default function Document() { + const gaMeasurementId = process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID; + return ( + {/* Google Analytics - Only included if environment variable is set */} + {gaMeasurementId && ( + <> +