Menu

A One-Line JavaScript Bug Broke My GA4 Tracking for Five Months
📰

A One-Line JavaScript Bug Broke My GA4 Tracking for Five Months

Reading 0:00
15s threshold

For five months, Google Analytics told me nobody on my site ever signed up, converted a file, or bought anything. Page views looked fine. Sessions looked fine. The key events report said zero, every day, and I read that as "the funnel is bad" instead of "the funnel is not being recorded".

The bug was one line. This is what it was, why nothing warned me, and how to check your own site in about a minute.

The setup

I run BatchSet, a set of browser-based image tools. GA4 is loaded the standard way, with the snippet Google gives you:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXX"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-XXXX'); </script>

Custom events came from a small typed helper in the app code, so components could call trackEvent({ action: "sign_up" }) instead of touching window directly:

function gtag(...args: unknown[]) { if (typeof window === "undefined") return const w =…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.