Skip to main content
TrustServers Knowledge Base

Tip: Start typing to get instant search results.

Table of Contents

How to block Ghost/Spam Visits in Google Analytics 4

Ghost (spam) visits in Google Analytics 4 are fake data that are inserted into your Google Analytics account without an actual visit to your website taking place.
They are sent by automated systems (bots) with the purpose of promoting unwanted websites, misleading through fake statistics, or creating an impression by recording spam referrers.

Ghost/spam Google Analytics visits do not actually load your website, they are not visits to your server, but they send data directly to Google Analytics’ Measurement Protocol using your Tracking ID. For this reason, they cannot be stopped at the hosting level.

To avoid distortion of your data that affects your marketing campaigns, and to avoid the appearance of malicious links in your Analytics, it is important to address the problem.

Valid Hostname Filter

This method blocks all entries with an invalid hostname.

Below we provide an example where we assume it concerns the website “www.trustservers.gr”. You need to replace the “Value” in step 3 with your own website (hostname).

  1. Log in to your GA4 account as an administrator of the Google Analytics account https://analytics.google.com
  2. Click on the “Admin” icon and in the “Property” column, select “Data Settings” and then “Data Filters”. There, click on “+ Create Filter”
  3. In this step we “filter” visits. We exclude visits that do not have “www.trustservers.gr” or “trustservers.gr” as hostname.
    Fill in the following:
    Filter name: Block Ghost Spam
    Filter type: Custom filter
    Dimension: Hostname
    Condition: does not match regex
    Value: ^(www\.)?trustservers\.gr$
    Action: Exclude
  4. Click on “Create”

The filter is activated immediately for future data (historical data is not modified).

Additional protection

  • We recommend periodically checking the “Acquisition > Traffic acquisition” reports for suspicious referrers
  • You can add known spam domains to the Referral Exclusion List (Admin → Data Streams → [Stream] → More Tagging Settings)
  • Don’t trust third-party “solutions”: We recommend avoiding plugins that promise “complete protection”. Ghost visits bypass your website and send data directly to GA. The filter in GA4 is the only reliable solution.
Was this article helpful?
Please Share Your Feedback
Πώς μπορεί να βελτιωθεί το άρθρο;
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.