From 83aedc847784ba730f872c77849797c49400dd16 Mon Sep 17 00:00:00 2001 From: jmeridth Date: Sat, 30 May 2026 00:35:04 -0500 Subject: [PATCH] feat: add Google Analytics 4 (GA4) measurement tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #78 ## What Add a GA4 measurement tag wired through `_config.yml`. The measurement ID `G-6DK8Y2SBT2` is set in `_config.yml` as `google_analytics_id`. `_includes/footer.html` emits the standard gtag.js snippet only when both conditions hold: `jekyll.environment == "production"` and `site.google_analytics_id` is set. ## Why PR #79 removed the dead `UA-1265430-2` tag because Universal Analytics was sunset by Google on July 1, 2023 and was collecting no data. This PR re-introduces analytics on the modern GA4 platform under a new property. Putting the measurement ID in `_config.yml` keeps future ID changes out of template HTML. The `jekyll.environment == "production"` guard prevents local `jekyll serve` runs from polluting GA4 — GitHub Pages sets `JEKYLL_ENV=production` automatically during deploy builds, so production traffic is captured without needing manual configuration on the server side. ## Notes - GA4 sets cookies and processes visitor IPs. For EU visitors this technically requires a cookie consent banner for GDPR compliance. Adding consent is out of scope for this PR; can be filed as a follow-up if the audience or legal posture changes. - The snippet is gated on both the environment AND the config key being set, so removing `google_analytics_id` from `_config.yml` cleanly disables analytics without touching template code. - The Liquid key `google_analytics_id` uses an underscore to match Jekyll's convention for templated variable names (`site.google_analytics_id`). Signed-off-by: jmeridth --- _config.yml | 1 + _includes/footer.html | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/_config.yml b/_config.yml index 7ec610cc..a0d1e417 100644 --- a/_config.yml +++ b/_config.yml @@ -29,6 +29,7 @@ twitter_username: lostechies github_username: lostechies #permalink: /:collection/:year/:month/:day/:title/ rss2json_api_key: "8rtxarjik93svbgojealqe4pzyta8qjzhcdhy40d" +google_analytics_id: "G-6DK8Y2SBT2" # Only supported by > Jekyll 3.7.0 #collections_dir: posts diff --git a/_includes/footer.html b/_includes/footer.html index 9a69c494..11625ba4 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -20,3 +20,14 @@ + +{% if jekyll.environment == "production" and site.google_analytics_id %} + + + +{% endif %}