We are using Google Analytics 4 (GA4) via Google Tag Manager (GTM), with Cookiebot as the Consent Management Platform (CMP).
Every so often Cookiebot is scanning our site.
In the web server logs, we can see that the user agent contains Cookiebot
as per Cookiebot's documentation.
We would like to filter that traffic out from GA4. The user agent string itself is not recorded in GA4 and I believe that is for privacy reasons.
What I had tried is:
- Using a GTM variable, trigger etc., look for Cookiebot in the user agent string (in
navigator.userAgent
) - Pass that on as a GA4 event parameter and user property
- The new property can be used to filter the traffic
That worked well when I mocked my own user agent string to the one used by Cookiebot.
But when the Cookiebot scan actually happened, then this doesn't seem to have worked and I can still see increased GA4 traffic and no indication of Cookiebot in my event parameter or user property.
How can I filter out Cookiebot web traffic from GA4?