Floryne Pierson
← All posts

50 fake sessions per day that GA4 didn't catch

Headless Chrome scrapers running real JavaScript. How I detected them and why the standard GA4 bot filter wasn't enough.

GA4 has a "filter known bots and spiders" toggle in Admin → Data Streams → More Tagging Settings. I had it enabled. It wasn't enough.

The bots hitting my site weren't using generic user-agent strings or old curl-based scrapers. They were headless Chrome instances running full JavaScript — loading the page, executing scripts, triggering custom events. From GA4's perspective, they looked like real users. They fired page_view. They had session IDs. Some even had engagement time.

I noticed the problem when I started cross-referencing two signals: GA4 session counts versus actual AI API calls per day. On a site where every meaningful interaction involves a server-side API call, the number of sessions should roughly correlate with the number of API calls. They didn't. Some days I had 60+ sessions with zero API calls. Those sessions had to be fake.

What headless Chrome looks like in the data

The pattern was consistent once I knew what to look for:

The standard GA4 bot filter catches crawlers that identify themselves — Googlebot, Bingbot, known scrapers that send accurate user-agent headers. It doesn't catch headless Chrome that spoofs a normal user-agent string. Those bots look identical to a real Chrome user on the network layer.

The detection approach

I added a client-side check that runs before the GA4 tag initialises. The logic: headless Chrome at its defaults exposes a few detectable properties that real browsers don't — WebDriver API flags set by the automation spec, browser environment signals that differ from genuine user sessions, and viewport characteristics typical of unattended execution contexts.

If the check identifies an automated browser, I skip loading GA4 entirely. No tag fires, no session is recorded. The bot scrapes the page content but leaves no analytics trace.

Important: the WebDriver flag is the most reliable signal — it's set by the spec when a browser is under automation control, and legitimate users never have it set. Sophisticated scrapers can patch individual signals, so a multi-signal check is more robust than relying on any single property.

Why this matters for conversion analysis

The practical impact isn't just inflated session counts. It's inflated non-converting session counts, which makes your conversion rate look worse than it is.

If you have 1,000 real sessions and 50 fake sessions, your denominator is 1,050. If 30 real users convert, you report a 2.86% conversion rate instead of 3.0%. That's a small distortion in absolute terms. But if you're trying to understand why a specific landing page doesn't convert, and 30% of its sessions are bot traffic with zero engagement, you're optimising for the wrong thing.

After filtering the bot traffic out, two pages that looked like outliers — high traffic, low conversion — moved to roughly average performance. The "problem" with those pages was that scrapers happened to target them more. There was no UX issue to fix.

What didn't work

Before writing the custom check, I tried a few things that didn't solve the problem:

IP blocking: Bots rotate IPs. You block one subnet, the next session comes from a different cloud provider. The maintenance burden isn't worth it for traffic at this scale.

Rate limiting by user agent: Bots spoof normal Chrome user agents. This catches nothing while potentially blocking real users.

GA4's built-in filter: As noted above — it only matches against a known list of bot user-agent strings. Headless Chrome with a spoofed UA isn't on that list.

The only thing that worked was running the detection client-side, before the analytics tag, using properties that the browser itself exposes and that scrapers tend to leave in their default state.

The limits of this approach

This isn't a comprehensive bot mitigation strategy. A determined scraper can patch navigator.webdriver, set a realistic screen resolution, and install fake plugins. If someone wants to scrape your content badly enough, they will.

What this catches is the commodity scraping — the mass-market tools that use default headless Chrome settings without any stealth configuration. That's most of the bot traffic on a small-to-medium content site. The check takes about 0.1ms client-side, adds no server load, and keeps analytics data clean without any third-party dependency.

For a solo-built product where every analytics decision is a resource allocation decision, clean data matters more than it looks. A fake session that inflates your bounce rate on a key landing page can send you on a week-long UX investigation for a problem that doesn't exist.