Issues with default consent state in Google Tag Manager (May 2022)

Update on 19th of May
This issue was fixed in Google Tag Manager this morning. We still haven't received any responses from the Google integration team.

Google Tag Manager was updated on 17th May 2022 breaking support for Consent mode affecting all consent management platforms (CMP) providing GTM templates. We are waiting for response from the Google integration team and until this has been fixed, a code must be placed right above the Google Tag Manager initialization code.

General information and temporary fix

We have noticed a serious problem affecting all CookieHub users using the CookieHub Google Tag Manager (GTM) template and Google Consent Mode (GCM). As of 17th of May 2022 04:00 (GMT), any tags using page view triggers ignore consent mode settings resulting in cookies being set prior to consent. This affects both tags with built-in GCM support and tags configured with additional consent.

Unfortunately, this issue cannot be fixed with changes to the GTM template or the CookieHub widget as it's caused by updated functionality in Google Tag Manager. We don't know at this point if the change is intentional or a bug but we are waiting for information from Google.

Temporarily this issue can be solved by placing the following code above the Google Tag Manager javascript code on your website:

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {'security_storage':'granted', 'functionality_storage':'granted', 'personalization_storage':'granted', 'ad_storage':'denied', 'analytics_storage':'denied', 'wait_for_update':500});

Technical details

Google Tag Manager uses triggers to identify when to fire tags. When CookieHub is implemented in Google Tag Manager with Consent mode, the CookieHub tag is triggered using the built-in Consent Initialization - All Pages trigger. This trigger is the first one fired to make sure a Consent Management Platforms (CMPs) can configure Google Consent mode before evaluating triggers for other tags.

Once the CookieHub tag has been loaded and the default consent configured using the Google Consent API, GTM should will move on to tags using the Initialization - All pages and then All pages triggers.

After the update on 17th of May, the Google Consent API command seem to be delayed and won't be set until after tags using the All pages triggers have been loaded. Since no default consent has been set at the time these tags are loaded, any additional consent settings are ignored and tags with built-in consent will run without checking for consent.

In GTM preview mode, you can see the order of actions and as shown on the screenshot below, the Consent Initialization trigger is the first one loaded but the default consent message (#4) is set after Container Loaded (All pages). This is happening even though these messages are set in the CookieHub tag which is triggered before any other tags.

Still need help? Contact Us Contact Us