Skip to main content

Google Analytic Exclusions GA4

Author: Jamie HoyleDate: June 27, 2025🧠 Summary / PurposeThis guide outlines how to configure Google Tag Manager (GTM) and Google Analytic...

E
Written by Evie Lynch
Updated this week

Author: Jamie Hoyle
Date: June 27, 2025


🧠 Summary / Purpose

This guide outlines how to configure Google Tag Manager (GTM) and Google Analytics 4 (GA4) to identify and exclude visits from specific crawler user-agents, such as MirrorWeb's. This ensures crawler traffic does not skew your analytics reporting.


🔍 Use Case / Scenario

Organizations that use crawlers (like MirrorWeb) to archive or scan their websites may see inflated or misleading metrics in GA4 if these visits are not filtered out. This process allows you to label that traffic as "crawler" and permanently exclude it from GA4 reporting.


🛠️ Step-by-Step Instructions

🔐 Prerequisites

  • Editor access to your GA4 property

  • Access and publishing rights for the GTM container that handles GA4 tagging


1. Create a Custom JavaScript Variable in GTM

  1. In GTM, go to Variables ▸ User-defined variables ▸ New.

  2. Select Custom JavaScript and paste the following code:

    function () {
      var ua = navigator.userAgent || '';
      return /mirrorweb/i.test(ua) ? 'crawler' : undefined;
    }
  3. Name the variable: cjs – traffic_type (crawler)

  4. Click Save

This function returns the string crawler only when the user-agent contains "mirrorweb".


2. Pass the Variable to GA4 as a Parameter

  1. Open your GA4 Configuration tag in GTM

  2. Under Configuration Parameters, click Add Parameter:

    • Field / Parameter Name: traffic_type

    • Value: #{{cjs – traffic_type (crawler)}}

  3. Save and Publish the container after testing


3. (Optional) Define a Rule in GA4 for Organization

  1. In Google Analytics, navigate to:

    • Admin ▸ Data Streams ▸ Web stream ▸ Configure tag settings ▸ Show all ▸ Define internal traffic ▸ Create

  2. Set:

    • Rule name: Crawler traffic

    • traffic_type value: crawler

    • Leave IP conditions empty

  3. Click Create

This step helps organize internal filters but is not mandatory.


4. Create a Data Filter in GA4 to Exclude Crawler Traffic

  1. Navigate to Admin ▸ Data Filters ▸ Create Filter

  2. Set the following:

    • Filter type: Internal traffic

    • Filter name: Exclude crawler traffic

    • Filter operation: Exclude

    • traffic_type equals: crawler

    • Filter state: Start with Testing, verify results, then change to Active

  3. Click Create

⚠️ Once active, GA4 will permanently exclude traffic labeled with traffic_type=crawler.


5. Validate and Monitor

  1. Publish your GTM container

  2. Wait for the crawler to revisit the site (MirrorWeb crawlers usually scan daily)

  3. Use DebugView in GA4 to verify that the traffic_type=crawler parameter is being sent

  4. Allow 24–36 hours for the exclusion filter to take full effect


Did this answer your question?