Consent Mode (Google Tags) - Custom Tag Template

IMPORTANT! The template update in December 2023 is a BREAKING change. Read more below.

The Consent Mode (Google tags) custom tag template is a tag template for Google Tag Manager’s community template gallery.

Resource
Vendor documentation
Blog post
Gallery entry
GitHub repo

December 2023 update

In the template update of December 2023, many breaking changes were introduced. For this reason, if you update to the latest version of the template, you will need to reconfigure all of the tags created with this template.

The template no longer uses a table for different default states. Instead, you can only configure one set of default states per tag. If you want to configure different defaults for some other region, you will need to create additional tags for each additional region configuration.

The update tag looks the same, but the underlying fields have also been changed. You will need to reconfigure update tags too.

Description

This tag lets you deploy the Consent Mode functionality offered by Google for controlling how data is accessed and collected by Google’s tags and pixels.

The template is also compatible with GTM’s consent features.

Instructions

The template lets you choose whether to send a default command (which sets the default state of consent on the page) or an update command (which updates the consent state after it has been determined by, for example, user input with a consent management system).

Please read the official vendor documentation for more information about consent states and the different options.

The default command

The purpose of the default command is to establish default values for consent signals on a page. Typically you would choose a default like denied for all states, but you might also populate the states from data available on the page or in cookies, for example.

If you use variables, make sure they return the string value granted when consent is granted and denied when consent has been denied.

You can also choose the wait_for_update timeout. This timeout determines how long Google’s tags wait for a possible update command, if the user’s consent choices are resolved asynchronously. When the default tag fires, any Google tags that would fire otherwise will wait for the timeout duration to allow for a possible update command to update the consent states.

Similarly, when you select default, you can choose the region to which the consent states apply. If you set it to all, it means that the consent states apply to visitors from all geographical regions. If you set it to a comma-separated list of region codes such as FI, DE, the consent states will only apply to visitors from those regions (Finland and Germany per the example).

You can have more than one tag with the default command firing on the page. For example, you might have one tag with all regions and one with FI region, using different settings for visitors from Finland.

You should use the Consent Initialization trigger type to fire the default command. That way no other tags will fire before consent state has been established.

The update command

You can create another tag with this template, this time with the update command.

In this case, set the different consent states to match what the user has consented to. If you use variables, make sure they return the string value granted when consent is granted and denied when consent has been denied.

Important note about the “Push dataLayer Event” option

If you are running multiple default commands on the page with different region settings, do note that the dataLayer event will be set to what the most recent default command included, even if the command didn’t apply to the user due to their geographical region.

This is an unfortunate outcome of how the Consent APIs currently worked, and I haven’t figured out a workaround for this.

Release notes

Date Changeset
1 December 2023 Complete overhaul of the template.
1 June 2021 Add compatibility with GTM’s new consent features.
17 October 2020 Initial release.