← Guides·Data Integrity

Data Integrity

Bot traffic in analytics: how to detect and filter it

Find the bots, ghost hits, and referral spam that GA4’s known-bot exclusion misses, and remove them in GA4, in BigQuery, or before they ever reach a tag.

David PombarSwiss army knife at Trackingplan
8 min read · 1660 words

GA4 removes the bots it already knows. Everything else is counted as a visitor: the scraper that runs a real browser, your own uptime checks, the competitor’s price monitor, and events sent straight to Google without anyone opening your site. Junk traffic does not look broken. It looks like a good day, which is why it is one of the quietest threats to data integrity.

This guide covers what GA4 filters for you and what it leaves in, the signals that give junk traffic away, ghost hits and referral spam, and the options to exclude it, from reversible report filters to blocking it before it reaches a tag.

What GA4 removes, and what it leaves in

GA4 excludes known bots automatically, and that is the only bot filter it has. Google’s known bot-traffic exclusion identifies them with its own research and the IAB International Spiders and Bots List. You cannot turn it off, and you cannot see how much it removed.

What the list does not cover reaches your reports as ordinary sessions:

A map of where junk traffic enters analytics: bots running a real browser on the site, internal and QA traffic, ghost hits sent straight to the collection endpoint, and referral spam.
Junk traffic enters at different points, so no single filter catches all of it.

The distinction matters because each kind leaves different traces and needs a different fix. A bot that runs your tags can only be stopped before the page loads them. A ghost hit can be spotted by what it gets wrong about your site.

The signals that give junk traffic away

No single dimension proves a session is a bot. A combination of them usually does. Start with the spike, then look at what the extra sessions have in common.

SignalWhat it looks likeWhere to check
EngagementEngagement time close to zero, engagement rate collapsing as sessions riseEngagement overview, segmented by source
DepthOne page per session, always the same landing pageLanding page report
HostnameA hostname that is not your domain, or (not set)A free-form exploration with Hostname
DeviceAn odd screen resolution, an outdated browser version, a missing languageTech details report
GeographyOne city or country with no history of sending trafficDemographic details
TimingA flat block of traffic that starts and stops on the hourHourly trend, compared with the same weekday
Sourcedirect or one referrer carrying all of the increaseTraffic acquisition
ConversionsSessions rise, sign-ups or purchases stay flatThe key event you trust most
A side-by-side comparison of a typical human session and a typical bot session across engagement time, pages, screen size, language, and timing.
One signal is a hint, several together are a pattern. Illustrative values.

GA4 does not show IP addresses or networks in its reports. Your CDN, web server, or firewall does. When the pattern points to automation, look at the same hours in those logs: a large share of requests from a few networks, often cloud and data-center ranges, confirms that the traffic did not come from your audience. Before you exclude it, check the calendar and your own launches. A newsletter, a TV slot, or a campaign can also produce a sharp, short spike with low engagement. The sudden drop guide has the same discipline for the opposite problem: rule out the calendar first.

Ghost hits and referral spam

A ghost hit is an event that reaches your property without a visit. In GA4, the usual route is the Measurement Protocol, which lets a server send events directly. It needs the stream’s measurement ID and an API secret, and Google is explicit: the API secret is private and must not be exposed in client-side code, because anyone who has it can send data to your property.

That makes the secret the thing to protect. A secret pasted into a browser script, a mobile app, or a public repository is an open door.

Two paths into GA4: a real visit that loads the page, runs the tag, and sends an event, and a ghost hit sent straight to the collection endpoint with a leaked API secret.
A ghost hit skips the site entirely, so anything that depends on the page, such as the hostname, is usually wrong.

Ghost hits tend to give themselves away by what they cannot know about your site: a hostname that is not yours, a page path that does not exist, a language or screen size that is missing, or a session with no session_start. Referral spam that runs a real browser is harder, because it does visit you. Its tell is a referrer that sends sessions with no engagement and no conversions, again and again.

One setting is often misread. GA4’s list of unwanted referrals does not remove traffic. It adds ignore_referrer=true to matching events so the referrer is not shown as a traffic source. It is the right tool for payment gateways and your own domains, not for spam: the spam sessions stay in your totals.

How to filter it in GA4

Pick the least permanent option that solves the problem. The options differ in one thing that matters more than convenience: whether you can undo them.

A ladder of filtering options from reversible to permanent: report comparisons and filters, exploration segments, a BigQuery view, and GA4 data filters.
Reversible options first. Data filters are permanent and only apply from the day you create them.
  1. Report comparisons and filters. Exclude a hostname, a source, or a landing page in the report you are reading. Nothing is deleted.
  2. Segments in explorations. Build a “likely bots” segment from the signals above, and compare it with everything else before you exclude anything.
  3. A view in BigQuery. If you export to BigQuery, keep raw events untouched and publish a cleaned view that the dashboards read. You can change the rules later and recompute history.
  4. Data filters. GA4’s data filters exclude internal traffic by IP address, developer traffic in debug mode, and traffic from hostnames you specify. Google states that filtered data is never processed, is not available in GA4 or BigQuery, and that filters do not affect historical data. Use them for certainties, such as a hostname that is not yours or your office IP range, not for hunches.

Whatever you exclude, write down the rule and the date. A quarter-on-quarter comparison that crosses the day a filter went live is comparing two different definitions of traffic.

Stop it before it reaches a tag

Filtering in GA4 cleans the reports. It does nothing for the ad platforms, the CDP, or the warehouse that received the same junk. The durable fixes sit upstream.

Layers where junk traffic can be stopped, from the CDN and firewall, through the site and tag manager, to a server-side container and GA4 settings.
The earlier a layer stops junk traffic, the more destinations it protects.

Where Trackingplan fits

Trackingplan, your digital analytics agent, does not label a visitor as human or bot. What it gives you is the part that makes the call possible. It reads every hit your real users and your servers send, learns a baseline from real traffic per hour of day and day of week, and posts the deltas that matter, per event, per property, per platform, with links to the affected hits. A traffic drop isn’t always a problem. A spike isn’t always a success.

That covers the server-side path too: hits sent through CAPI, the Measurement Protocol, or your own backend are visible in the same way as browser hits, which is where a leaked secret shows up first. For how the baseline and the alerts work, see monitoring.

Frequently asked questions

Does GA4 filter bot traffic automatically?

Partly. GA4 excludes traffic from known bots and spiders, identified with Google research and the IAB International Spiders and Bots List. You cannot turn that exclusion off and you cannot see how much it removed. Bots that are not on the list, scripts that run a real browser, and hits sent straight to Google without visiting your site are not covered.

How do I know if a traffic spike is bots?

Look at what the extra sessions did, not how many there are. Bot sessions tend to have almost no engagement time, a single page, one landing page or one country, an unusual hostname or screen size, and a start and end that look scheduled. Then check the same hours in your server or CDN logs: if the requests come from a handful of networks or data centers, it is not your audience.

What is the safest way to exclude bot traffic in GA4?

Start with reversible options: comparisons and filters in reports, segments in explorations, or a view in BigQuery. Use data filters only for patterns you are sure about, such as a hostname that is not yours, because Google states that excluded data is never processed and that filters do not affect historical data.

What are ghost hits in GA4?

Ghost hits are events that reach your property without anyone visiting your site, usually sent with the Measurement Protocol. In GA4 that protocol needs an API secret, which Google says must stay private and out of client-side code. If it leaks, anyone can send events to your property, so keep it on your server and rotate it if you suspect it was exposed.

David PombarSwiss army knife at Trackingplan

Read more from David, a Senior Product Strategist with 18+ years in digital product development and an atypical error detection knack.

Trackingplan

See everything. Miss nothing.

Your implementations audited around the clock with real-time, real-user data. Real-time alerts about errors or changes in your data, campaigns, pixels, privacy and consent. Let AI flag issues before they cost you.