From d439acbdea10a9fca3a29cd7e44a5d1823df44ad Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 1 Dec 2025 17:27:43 -0500 Subject: [PATCH] Add hidden analytics opt-out feature via ?kr=1 parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users can now disable analytics by visiting homepage with ?kr=1: - Detects ?kr=1 parameter and sets localStorage + cookie - Analytics script checks both before loading - Persists across sessions (10 year cookie + localStorage) - ?kr=0 re-enables analytics if needed - Clean URL redirect after setting preference - Fully client-side, privacy-focused implementation Technical details: - localStorage primary (instant, no server traffic) - Cookie fallback (315360000s = 10 years) - window.analyticsDisabled flag for runtime checks - Gauges analytics respects opt-out flag 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- kjvstudy_org/templates/base.html | 55 ++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/kjvstudy_org/templates/base.html b/kjvstudy_org/templates/base.html index 9c8da97..fc3ba95 100644 --- a/kjvstudy_org/templates/base.html +++ b/kjvstudy_org/templates/base.html @@ -31,6 +31,33 @@ + + + {% block head %}{% endblock %} @@ -2356,19 +2383,21 @@ })(); {% if not disable_analytics %} - // Gauges analytics - var _gauges = _gauges || []; - (function() { - var t = document.createElement('script'); - t.type = 'text/javascript'; - t.async = true; - t.id = 'gauges-tracker'; - t.setAttribute('data-site-id', '6834bd650d851064ae28dc13'); - t.setAttribute('data-track-path', 'https://track.gaug.es/track.gif'); - t.src = 'https://d2fuc4clr7gvcn.cloudfront.net/track.js'; - var s = document.getElementsByTagName('script')[0]; - s.parentNode.insertBefore(t, s); - })(); + // Gauges analytics (respects kr=1 opt-out) + if (!window.analyticsDisabled) { + var _gauges = _gauges || []; + (function() { + var t = document.createElement('script'); + t.type = 'text/javascript'; + t.async = true; + t.id = 'gauges-tracker'; + t.setAttribute('data-site-id', '6834bd650d851064ae28dc13'); + t.setAttribute('data-track-path', 'https://track.gaug.es/track.gif'); + t.src = 'https://d2fuc4clr7gvcn.cloudfront.net/track.js'; + var s = document.getElementsByTagName('script')[0]; + s.parentNode.insertBefore(t, s); + })(); + } {% endif %}