Ways to stop referral spam polluting your analytics and server: filters, server rules, firewalls and plugins, and when each one makes sense.
In this article 3 sections · 3 min read
Referral spam shows up as fake visits from strange domains in your analytics. Some of it never touches your website at all; some is real bot traffic hitting your server. Either way, it distorts your data and can waste server resources.
01Two types of referral spam
- Ghost spam: fake hits sent directly to your analytics property without visiting your site. Server rules cannot stop these; analytics filtering can.
- Crawler spam: bots that actually visit your site, often repeatedly. These can be blocked at the server or firewall.
Google Analytics 4 is less affected by ghost spam than older versions, but crawler spam still appears.
02Ways to block it
1. Filter it in Analytics
Use data filters and segments to exclude suspicious domains from reports. This cleans your data without affecting your site.
2. Block at the server
On Apache servers you can deny requests based on the referring domain in the .htaccess file. On Nginx, the equivalent is a rule in the server configuration. See editing .htaccess safely.
3. Use a firewall or CDN
Services such as Cloudflare let you block countries, user agents or referrers and filter known bad bots, which is often the most effective option for heavy traffic.
4. Use a security plugin
On WordPress, security and firewall plugins can block bad bots and spam referrers with less technical effort.
5. Report spam
Where spam sites abuse search or advertising services, you can report them to the relevant platform.
03Avoid overdoing it
- Do not block legitimate referrers or search engine crawlers.
- Keep block lists maintained; spam domains change often.
- Watch for side effects after adding server rules.
Clean data is the foundation for good decisions. Our analytics and conversion tracking service can set up filtering and reporting you can trust. Related: internal site search spam.
Our team can review your situation and tell you exactly what to fix first.
