After deploying GA4 click tracking (#763) to krillswarm.com, only the
auto-collected page_view event ever reached GA4 / Firebase. Clicking the
Windows installer, app-store tiles, copy buttons, etc. produced no
download / copy_install_cmd / outbound_click events — in Realtime,
DebugView, or anywhere. Grepping the deployed HTML showed the listener
code was present (gtag('event', 'download', etc.), so it looked shipped.
Chirpy’s compress_html layout (enabled in production via
compress_html.ignore.envs: [development]) strips all newlines inside
inline <script> blocks — the deployed listener was a single line with
zero newlines. The injected script used // line comments. Once collapsed
to one line, each // commented out the entire remainder of the script,
producing SyntaxError: Unexpected end of input; the listener IIFE never
ran. The separate gtag('config', …) script had no // comments, so
page_view kept firing — which masked the breakage and made it look like
“events just aren’t showing up” rather than “the script is dead.”
Replaced every // line comment in docs/_includes/analytics/firebase.html
with /* … */ block comments, which survive newline-stripping. Verified by
extracting the listener <script> from the compressed _site/index.html
and running node --check on it (was SyntaxError, now OK), and by a
headless-browser probe that dispatches clicks and reads window.dataLayer:
all 8 expected gtag('event', …) calls now fire, internal nav fires none.
// line comments in an inline <script> that passes through
compress_html (or any minifier that collapses newlines). Use /* */.
Same hazard applies to inline scripts in _layouts/home.html, etc.// comment leaves the strings intact while
killing the script. Validate the compressed output: extract the inline
analytics script from _site and node --check it, and/or run a Playwright
smoke test asserting a click pushes a gtag('event', …) into dataLayer.