Skip to main content

Consent Mode with gtag

This page explains how the banner handles Google Consent Mode on a site with gtag.js and without Google Tag Manager. It shows who sends default and update, and how to get Basic or Advanced.

Who this is for​

For you if you have the Google tag (gtag.js) in the page code. With Google Tag Manager, see With Google Tag Manager.

Prerequisites​

Before you start, check that:

  • the banner snippet is on the page. See HTML snippet;
  • Google Consent Mode is on in the web space. New web spaces already have it on. In Cookie Banner > Advanced settings, the Support for Google Consent Mode dropdown shows Activate.

Who sends what​

CommandWho sends itWhen
gtag('consent', 'default', …)the banner snippet, at the top, synchronouslybefore every Google tag the page loads after the snippet
gtag('consent', 'update', …)the bannerwhen the visitor chooses, and when it loads a consent already saved
{ event: 'avacy_consent_update' }the bannerright after the update

The default​

The snippet sends a single global default. All seven consent types (ad_storage, ad_user_data, ad_personalization, analytics_storage, functionality_storage, personalization_storage, security_storage) start as denied. wait_for_update is 500 ms.

The snippet does not send its default in two cases:

  • the page already has a consent default in the dataLayer;
  • the page has the Avacy GTM template, which sets the default on its own.

Add your own consent default only if you want different values (see Wait times).

The updates​

The banner sends the update with the seven types set to granted or denied, based on the visitor's choices. A type without a choice stays denied.

Right after the update, the banner pushes the avacy_consent_update event to the dataLayer, with no other data. The event is for Google Tag Manager tags that are not Google tags. The order is always update, then event. The event also fires with a consent already saved.

Basic and Advanced​

The banner has no Basic or Advanced switch. The mode depends on how the page loads the Google tags.

According to Google, in Basic mode Google tags do not load until the visitor interacts with the banner. In Advanced mode they load when the page opens, with the consent defaults (source).

ModeWhat the page doesWhat the banner does
AdvancedThe Google tag loads immediately, after the snippet.Sends the default before the tag, then the updates.
BasicThe Google tag is marked and stays on hold.Unblocks the marked scripts after the update, when the required consent is granted.

Advanced​

  1. Put the banner snippet in the <head>, near the top, before the Google tag.
  2. Leave the Google tag as it is, without marking it.
<head>
<!-- 1. Banner snippet, first -->
<script src="https://TENANT.avacy-cdn.com/v3/avacy-cmp-web.js?webspace=WEB-SPACE-UUID"></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>

Replace TENANT, WEB-SPACE-UUID and G-XXXXXXXXXX with your values. Copy the real snippet from the dashboard.

Basic​

Mark the Google tags so they stay on hold until consent. Steps, example and the table of purpose numbers are in Google tags with gtag, without GTM.

Wait times (wait_for_update)​

wait_for_update is the time, in milliseconds, that Google tags wait for an update before using the default.

Who sends the defaultValue
Banner snippet500 ms, fixed
Avacy CMP GTM templateWait for update field, default 2000 ms, editable

The snippet value cannot be configured. For a different value, send your own consent default before the snippet. The snippet then does not send its own.

With Google Tag Manager​

The Avacy CMP GTM template sends the default, including per region, with the values chosen in the tag. It marks the page with __AVACY_GTM_CONSENT_TEMPLATE__, and the banner sends only the updates. The template guide is Install the banner with Google Tag Manager (in Italian).

Verify​

  1. In the browser console, run dataLayer.map(e => e.event || e[0] + ' ' + e[1]).
  2. Check that consent default appears before js and config.
  3. Make a choice in the banner and run the command again. consent update must appear, followed by avacy_consent_update.
  4. Turn on debug mode and check the result. See Google tag order and debug mode.

Common problems​

The most frequent problems:

  • The console reports LATE: a Google tag ran before the default. Put the snippet before the tag. If the tag goes through Google Tag Gateway, see Google Tag Gateway;
  • All types stay denied after accepting: check which button was pressed. The X at the top (Continue without accepting) and Reject all set all types to denied. Accept cookies sets them all to granted;
  • The default is not in the dataLayer: the page may use a dataLayer with a different name. The banner reads only dataLayer.

Last updated: 10/11/2026.