David Stockdale's Scrapcode

New EU Consent Requirements for Google Analytics

Recently Google introduced new consent requirements for Google Analytics in the European Union (EU), aiming to enhance user privacy and data protection.

What Are Google’s New EU Consent Requirements?

Google’s new EU consent requirements for Google Analytics mandate that website owners obtain explicit consent from users before collecting and processing their data for analytics purposes.

This means that users must be informed about the data being collected, why it’s being collected, and given the opportunity to consent before any data is gathered.

Implementing Consent Settings

To comply with these requirements, website owners can implement consent settings directly within their website’s code.

One effective way I’ve found to do this is by setting various consent settings to false by default and only granting consent if the user is within the Great Britain (GB) region.

Simply place this script in the “header.php” file of your child theme:

		window.dataLayer = window.dataLayer || [];
		function gtag(){dataLayer.push(arguments);}
		gtag('consent', 'default', {
			'ad_storage': 'granted',
			'analytics_storage': 'granted',
			'ad_user_data': 'denied',
			'ad_personalization': 'denied'
		gtag('consent', 'default', {
			'ad_user_data': 'granted',
			'ad_personalization': 'granted',
			'region': ['GB']

How Does This Code Work?

The provided JavaScript code sets default consent settings for Google Analytics.

Initially, data collection for advertising and personalization purposes is denied, ensuring user privacy by default.

However, for users within the GB region, consent is explicitly granted for these purposes.

The code specifically targets users within the GB region to ensure compliance with EU regulations, as Great Britain adheres to the same data protection standards as the EU.

By focusing on a specific region, website owners can streamline the consent process while ensuring compliance with applicable regulations.

If this has helped you please leave a like and if you have any problems you want solved feel free to leave a comment!

Leave a Reply