Exclude Cookiebot bot traffic in GA4
To exclude the spikes in your GA4 acquisition reports, perform the steps in your sGTM container. Cookiebot itself advises creating a filter for internal traffic in GA4, but this doesn’t always work. In your sGTM container, you can exclude this.
Open your GTM server container.
Go to ‘Variables’.
Create a new ‘User-defined variable’.
Name the variable “ip_override”.
Choose ‘Event Data’ as the variable type and enter “ip_override” as the ‘Key Path’.
Save this variable.
Create a new ‘User-defined variable’.
Name the variable “user_agent”.
Choose ‘Event Data’ as the variable type and enter “user_agent” as the ‘Key Path’.
Save this variable.
Go to ‘Triggers’.
Open the trigger for the GA4 tag.
Add the following condition to the trigger: ‘user_agent’ does not contain “Cookiebot”.
Add the following condition to the trigger: ‘ip_override’ does not match RegEx “35.198.160.49|34.159.168.195|35.246.191.14|34.107.102.47|34.141.10.24|35.246.143.2|34.159.247.222|35.198.137.6|34.159.86.126|35.198.78.207”.
Make sure to check the Cookiebot IP address list to know which IP addresses you should add in this condition: Cookiebot IP list. This list may have been updated since the publication of this helpdesk article.
Save the trigger and publish the sGTM container.
Open your GTM server container.
Go to ‘Variables’.
Create a new ‘User-defined variable’.
Name the variable “ip_override”.
Choose ‘Event Data’ as the variable type and enter “ip_override” as the ‘Key Path’.
Save this variable.
Create a new ‘User-defined variable’.
Name the variable “user_agent”.
Choose ‘Event Data’ as the variable type and enter “user_agent” as the ‘Key Path’.
Save this variable.
Go to ‘Triggers’.
Open the trigger for the GA4 tag.
Add the following condition to the trigger: ‘user_agent’ does not contain “Cookiebot”.
Add the following condition to the trigger: ‘ip_override’ does not match RegEx “35.198.160.49|34.159.168.195|35.246.191.14|34.107.102.47|34.141.10.24|35.246.143.2|34.159.247.222|35.198.137.6|34.159.86.126|35.198.78.207”.
Make sure to check the Cookiebot IP address list to know which IP addresses you should add in this condition: Cookiebot IP list. This list may have been updated since the publication of this helpdesk article.
Save the trigger and publish the sGTM container.
Updated on: 08/10/2024
Thank you!