Articles on: Client Side

Triggering the consent update the right way

When someone visits your site for the first time, they have not yet given consent. Consequently, the Google Tag and the page_view event tags will be activated at a time when consent has not yet been given. As a result, these tags will not be fully activated. When the visitor updates their consent, the Google Tag and page_view event tags must be fired again, this time with the fully updated consent.




There are two ways to fix this issue:
Create a trigger to update the consent
Trigger all tags on the consent update



Cookiecode


Depending on the CMP, it may be that a specific DataLayer event occurs when consent is updated. For example, with Cookiecode, you can set up two DataLayer events: cookiecode.consent_all & cookiecode.consent_update.

Create a new trigger for a custom event.

Give the event the following name: cookiecode.consent_update|cookiecode.consent_all



Make sure to check the following options within your cookiecode tag



Add the new consent update trigger to the Google Tag, page_view event tags, and all other tags that should activate on every page.





It may be possible to use the interaction with the actual cookie banner as a trigger. This way, after updating the consent when that specific interaction has occurred, you can reactivate the tags.

Note! You should first test this in preview mode to determine if this is possible for your CMP.

The DataLayer event used to show the consent on every page should be added as a custom event trigger. (This varies by CMP)



Add the interaction with the cookie banner as a click trigger as well.



Add both triggers to a trigger group so that both triggers must be present on a page before the trigger group can activate.



Add this trigger group to all tags that need to be activated on every page, and therefore are (partially) blocked on page 1 of session 1 due to consent not yet being given.





Cookiebot


After a visitor has given consent via a Cookiebot banner, a DataLayer event named ‘cookie_consent_update’ appears on every page. You can set all triggers for a complete setup on this event, including the Google Tag and the page_view event tags. However, if you do this, make sure that all other event tags can never occur before the cookie_consent_update, but always after it.

Create a trigger for the custom event with the name cookie_consent_update



Replace the triggers of all tags that need to occur on every page with this trigger.



Replace all triggers of tags that can occur before cookie_consent_update in the DataLayer in the following way:

Triggering based on thank you pages is done via a specific cookie_consent_update trigger.



Based on a DataLayer event that can trigger earlier than cookie_consent_update, add this to a trigger group.



Updated on: 21/08/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!