Skip to main content

Integration with Google Consent Mode

Consent Mode V2 is an integration that maximizes control and transparency in managing user consent on your website: until the user has given consent, their data will not be saved.

WARNING: For any issues encountered during the integration of Google Consent Mode with the CMP, please reach out to our technical support team first at support@avacysolution.com. Google support will be involved only if necessary.

For more informations check the official Google documentation guide.

Looking for the whole path, from activation to verification? Start from Avacy for Google Consent Mode and IAB TCF.

To use Google Consent Mode is essential to understand the difference in behavior and configuration between the two modes:

  • Basic Consent Mode: Google tags are blocked from loading until the user interacts with the consent banner. No data is sent to Google before consent. If consent is denied, the tags are never fired.
  • Advanced Consent Mode: Google tags load immediately (e.g., upon page initialization). Before the user grants consent, the tags function in a "restricted" mode: they do not read/write cookies but send cookieless pings containing consent status and non-identifying events. This allows Google to model conversions to recover lost data.
    • Configuration Note: For Google Ads tags, you can further strip ad click identifiers (like GCLID) from these pings by ensuring ads_data_redaction is set to true.

NOTE: Advanced mode involves data transmission (pings) before explicit consent, although no cookies are set. Consult your legal department regarding your specific jurisdiction.

From the Google Tag Manager dashboard, click on Administration and then Container Settings

Alt text

From here, check the box for Enable Consent Overview.

Alt text

New webspaces (banner v3). Google Consent Mode is already on. You have nothing to activate. To check it, open the dashboard of the webspace, go to Cookie Banner and then Advanced settings. The Support for Google Consent Mode dropdown shows Activate.

If the dropdown shows Deactivate, select Activate and publish the banner with Save and publish Cookie Banner.

Banner v2 (legacy panel). In the Cookie Banner section, under Advanced settings, find Support for Google Consent Mode and select Activate.

Once Consent Mode is on, the preferences panel of the cookie banner shows a new section. It contains the purposes for managing the Google consent indicators.

Alt text

The purposes in the Avacy cookie banner are associated with the consent indicators as follows:

The definitions of the indicators are the text of Google's official documentation: Consent Mode.

GTM Consent IndicatorPurpose on Cookie BannerGoogle definition
ad_storageManaging cookies or advertising device identifiersEnables storage, such as cookies (web) or device identifiers (apps), related to advertising.
ad_personalizationReceiving personalized advertisingSets consent for personalized advertising.
ad_user_dataSharing data with Google for its own advertising purposesSets consent for sending user data to Google for online advertising purposes.
analytics_storageActivation of Google Analytics featuresEnables storage, such as cookies (web) or device identifiers (apps), related to analytics, for example, visit duration.
functionality_storageStoring technical settingsEnables storage that supports the functionality of the website or app, for example, language settings.
personalization_storageContent personalizationEnables storage related to personalization, for example, video recommendations.
security_storageTracking for security purposesEnables storage related to security such as authentication functionality, fraud prevention, and other user protection.

When you use IAB TCF together with Google Consent Mode, you can let Google read consent from the IAB TCF string.

Where to find it. On the Avacy dashboard, open the v3 banner, go to Advanced Settings and find the Google Consent Mode dropdown. Below it there is the switch Allow Google to read consent from the IAB TCF string.

What it does. When the switch is on, the banner sets enableAdvertiserConsentMode: true in the TCF data (TCData). Google tags then derive ad_storage, ad_user_data and ad_personalization from the IAB TCF string. analytics_storage always comes from Consent Mode. Consent Mode and TCF can be active together.

Default. The switch is on by default. If you turn it off, the banner does not set the flag and Google uses only the Consent Mode signals.

Without IAB vendors. If no IAB vendors are configured, the switch is shown as on and cannot be changed, with the note Without IAB vendors the flag stays off. In this case the banner does not set the flag. Without IAB vendors, the TCF purposes do not describe a choice about Google. If IAB TCF is not configured at all, the note says Available once the IAB TCF vendors are configured.

How to check it. Open the browser console on a page with the banner and run:

__tcfapi('getTCData', 2, (d) => console.log(d.enableAdvertiserConsentMode));

It prints true when the flag is set. When it is not set, the value is undefined.

For more details, see the Google guide on TCF strings and Consent Mode.

Preliminary Steps: Installing the Avacy CMP template​

Install the "Avacy CMP" template from the Gallery and create its tag on the Consent Initialization - All Pages trigger: follow the guide Integration via Google Tag Manager.

With GTM the work is split like this:

  • the template sends the Consent Mode default, with the values chosen in the tag;
  • the banner sends the updates (gtag('consent', 'update', …)) when the user chooses and on every page with a consent already saved.

Configuration​

After performing the above steps go to the container and, in the tag list, click on the shield icon at the top right.

Alt text

A summary of the tags will be displayed, showing those that have not yet been configured with Google Consent Mode and those that have been correctly configured.

Some tags are configured with built-in consent indicators (usually Google tags, e.g., Google Analytics) and automatically adjust their tracking services based on these indicators. Other tags do not have built-in consent indicators, so to integrate Consent Mode, you need to set additional consent indicators.

Alt text

Let's take the integration of a Facebook Pixel as an example.

Once you have added the tag to the container, click on the tag to open its details. Click the pencil icon in the Tag Configuration section and scroll down to Advanced Settings. Then, click on Consent Settings and select the option Additional consent required for tag firing.

Alt text

As shown in the picture, manually set one or more consent indicators supported by Google, described in the previous table.

In the Triggers section, create a new "Custom Event" trigger and set the event name to avacy_consent_update.

Alt text

Next, link this trigger to the Facebook Pixel in the "Triggering" section of the tag.

Repeat the procedure for each tag to which you want to apply Google Consent Mode.

Testing​

At this point, following the Facebook Pixel example, the tag should only activate if consent is given for the purpose related to the ad_storage indicator, in other words, if that particular feature is accepted from the platform's cookie banner.

Alt text

We can verify from the container preview that, by checking the Managing cookies or advertising device identifiers purpose in the cookie banner, the avacy_consent_update event is indeed triggered through the dataLayer API. At this point, the tags triggered by this event will automatically determine whether they should be activated based on the consent indicators we specified for them.

In this case, since we set the ad_storage indicator for the Facebook Pixel, we can verify from the debugger that the tag is activated when the event is triggered.

Alt text

Similarly, in the Consent tab of the debugger, we can check how the consent indicators have changed based on the preferences expressed.

Alt text

As a cross-check, we can activate all purposes except those required to activate the Pixel, and verify that it remains effectively blocked.

Alt text

We then return to the debugger and verify that the consent indicators are set accordingly:

Alt text

Finally, we verify that the Facebook Pixel remains deactivated because the necessary consent indicator was not provided.

Alt text

If the result is as expected, the preventive block for the Pixel has been successfully configured.

Example: blocking a Google tag (GA4 and Google Ads)​

In Basic mode, Google tags are blocked too, until the user chooses. The steps are the same as for the Facebook Pixel. Only the consent indicators change.

  1. Open the tag (for example the Google tag of GA4, or a Google Ads tag).
  2. In Advanced Settings, open Consent Settings and select Additional consent required for tag firing.
  3. Add the consent indicators the tag needs:
    • GA4: analytics_storage.
    • Google Ads: ad_storage, ad_user_data and ad_personalization.
  4. In Triggering, remove the triggers that fire at page load (such as "Initialization" or "All Pages"). Add the "Custom Event" trigger with the event name avacy_consent_update.
  5. Repeat for every Google tag you want to block.

The tag now waits. It fires when the avacy_consent_update event arrives and the indicators you selected are granted. If the user refuses them, the tag never fires.

The Avacy banner pushes this event in the dataLayer right after every Consent Mode update. It pushes the same event on the pages of a visitor who has already chosen. The event has no other data: it is { event: 'avacy_consent_update' }. The update with the consent values comes just before it.

To check it, follow the steps of the Testing section above, with your Google tag instead of the Pixel. In the debugger, the tag must appear under "Tags Not Fired" until the consent is given.

In Advanced mode, Google tags (GA4, Google Ads, Floodlight) must load immediately to send consent pings.

Use standard triggers like "Initialization" or "All Pages". Do not use the avacy_consent_update trigger for these tags.

Ensure that "Built-in Consent Checks" are active on the Google Tag (usually active by default).

Result: Google tags will fire immediately. If consent is denied, GTM automatically restricts them to cookieless pings. If consent is granted, they process data normally.

NOTE: For non-Google tags (like Facebook Pixel), continue using Option A (Basic), as they do not support Google's consent pings and should likely remain blocked until consent is granted.

Switching between Basic and Advanced​

The mode is not a switch in the Avacy dashboard. It depends on what the page does with the Google tags:

  • Advanced: the Google tags load at once. They are not marked and not blocked.
  • Basic: the Google tags are blocked. They load only after the user's consent.

Switching can require changes to the code of the page or of the container. This is expected: the change is on the tags, not only in the banner. After each change, publish the banner or the container and check it again.

From Advanced to Basic​

Block the Google tags. Choose the way that matches your installation.

  • With Google Tag Manager. For every Google tag, set Additional consent required for tag firing with the indicators it needs. Replace its triggers with the avacy_consent_update event. The steps are in Option A.
  • With gtag.js. Mark the Google scripts so that Avacy blocks them. See Basic with gtag.js.

Another way is to turn off Consent Mode in the banner. In Cookie Banner > Advanced settings, select Deactivate in the Support for Google Consent Mode dropdown. Then publish the banner. With this choice the banner no longer sends the Consent Mode signals to Google. The Google tags are then blocked like any other vendor, with the preemptive block.

With Google Tag Manager, the Consent Mode default is set by the Avacy CMP template, not by the banner. If you turn Consent Mode off in the banner, check the Default consent values of the template: the banner will not send any update after them.

From Basic to Advanced​

  1. Remove the block from the Google tags. With GTM, delete the additional consent and put back a trigger such as "Initialization" or "All Pages". With gtag.js, remove the marking from the Google scripts.
  2. Check that Consent Mode is on: Cookie Banner > Advanced settings > Support for Google Consent Mode must show Activate.
  3. Publish the banner, or the GTM container.

On a v3 webspace, publishing the vendors does not turn Consent Mode on again. The dropdown keeps the value you chose.

NOTE: Advanced mode sends cookieless pings before the choice. See the note in Basic vs Advanced.

Using gtag.js without Google Tag Manager​

If the Google tag is in the code of the page and not in a GTM container, Avacy still handles the Consent Mode. You must install the Avacy snippet first: see Integration via HTML code.

Advanced with gtag.js​

You do not need any other step.

  1. Put the Avacy snippet as high as possible in the <head>, before the Google tag.
  2. Leave the Google tag as it is, not marked.
<head>
<!-- 1. Avacy snippet, first -->
<script src="..."></script>

<!-- 2. Google tag, as usual -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
</head>

With Consent Mode on, the snippet sends the Consent Mode default before the Google tag. The default is denied for all the consent indicators, with wait_for_update set to 500 ms. When the user chooses, the banner sends the update.

Do not add your own gtag('consent', 'default', ...). If the page already has one, Avacy leaves it and does not send its own.

Basic with gtag.js​

Mark the Google scripts, so that they do not run until the user gives consent. Each script gets three changes:

  • type="text/avacy-blocked", so the browser does not run it (any type that the browser does not run works);
  • data-avacy-requires, with the Consent Mode purpose the script needs;
  • for an external script, data-avacy-src with the real address, and no src.
<!-- external script: gtag.js -->
<script type="text/avacy-blocked"
data-avacy-src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"
data-avacy-requires="gcm:purpose:4"></script>

<!-- inline script: configuration -->
<script type="text/avacy-blocked"
data-avacy-requires="gcm:purpose:4">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>

The number after gcm:purpose: is the id of the purpose in the banner:

IdConsent indicator
1ad_storage
2ad_user_data
3ad_personalization
4analytics_storage

For GA4 use gcm:purpose:4. For Google Ads use gcm:purpose:1,2,3. With more ids, the user must grant all of them.

When the user chooses, the banner sends the Consent Mode update first. Then it releases the scripts whose consent is granted. If the user refuses, the scripts stay blocked.

Two conditions apply:

  • The marked scripts are released only if the Avacy snippet is on the page.
  • The component that releases the scripts turns on when at least one vendor of the webspace has a preemptive block URL and is published. Without it, the marked scripts stay blocked. To set the URL, go to Vendors List, select a vendor and click Other actions, then Edit preemptive block URL. See Configure preemptive block via SaaS and WordPress plugin.

The markup of the manual preemptive block with data-managed="as-oil", described in Configure preemptive block manually, is still read and translated by the banner. It cannot name a Consent Mode purpose: it names a vendor or IAB purposes. For a Google script, use data-avacy-requires as above.

To check it, open the page without choosing: the Google scripts must not appear in the Network panel. Accept the analytics purpose: the scripts load.