Dani 5,664 The Queen of DaniWeb Administrator Featured Poster

How on earth do I get Google Analytics to filter out the tremendous amount of referral spam that is showing up in my reports?!

For those of you who are unaware of what I'm talking about, do a google search for "google analytics referral spam" to see what I mean. Unfortunately the many articles on how to remove it that I've come across all seem to be about filtering out specific domains ... nothing that is able to detect it automatically. Or am I mistaken?

Dani AI

Generated

As notes, trying to block individual domains is a losing battle — referral spam arrives two ways: crawler spam (bots that actually hit your site) and ghost spam (fake Measurement‑Protocol hits that never touch your server). Ghost spam often shows fake hostnames or “(not set)”, so domain blacklists alone won’t stop it. (searchenginejournal.com)

The most reliable, low‑risk fix for Universal Analytics is an “Include only valid hostnames” view filter. Workflow: create a test view, open Audience → Technology → Network → Hostname and list every legitimate hostname (your domains, subdomains, payment/checkout domains, CDNs and known services such as translate.googleusercontent.com). Build a regex of those hostnames, apply a Custom → Include → Hostname filter to the test view, verify carefully, then apply to your main reporting view. Example regex:

^(example\.com|www\.example\.com|checkout\.shopify\.com|translate\.googleusercontent\.com)$

Test before you commit and always keep an unfiltered/raw view. (freshegg.co.uk)

If you’re on GA4, use Admin → Data Streams → Configure tag settings → List unwanted referrals to stop listed domains from being counted as referrals (Analytics flags matching events with ignore_referrer=true) — that affects attribution but does not erase the incoming spam hit. GA4 also tightens Measurement Protocol by requiring an API secret for server-to-server events, which reduces the ghost‑spam surface compared with old UA; server‑side tagging can further help. (developers.google.com)

Extras and cautions: enable Google’s bot filtering where available, block obvious crawler spam at the CDN/firewall level, monitor Real‑time/DebugView for new patterns, and use segments/explorations to clean historical data because filters are forward‑looking only. Keep a backup view and review hostnames periodically — spammers change tactics. (creative.nd.edu)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.