Troubleshoot consent mode with Tag Assistant

This article is for developers and administrators that want to verify and troubleshoot their consent mode implementation on their website. For TCF implementations on websites, see Troubleshooting TCF. To verify app implementations, see instructions for Android and iOS.

You can check your consent mode implementation for:

  • Whether your website sets the correct default consent state before any tags fire. The appropriate default depends on your organization's policies.
  • Whether your website updates consent states correctly after visitors grant or deny consent.
  • Which tags check for which consent types.
  • Whether the required consent types were granted when each tag triggered, and whether the tag passed the checks for any additional required consent.

Tag Assistant supports the following consent mechanisms:

Before you begin

You can use Tag Assistant on all browsers. For the best troubleshooting results, use Google Chrome and install the Tag Assistant Companion browser extension.

Verify consent mode works

The following steps show you how to debug consent mode. If you have set region-specific defaults or consent banners, repeat these steps with different simulated geographic locations. Learn how to set locations in Chrome.

gtag.js

To verify your consent setup for websites, start a new Tag Assistant session:

  1. Open Google Tag Assistant
  2. Enter your website's URL. A new tab with your website opens.

  3. On your website, open the cookie banner and accept all parameters.

  4. In Tag Assistant, verify if the page set the default consent correctly:

    1. In the Summary, select the earliest Consent event.
    2. In the API Call section, check that the following parameters were set: ad_storage, ad_personalization, ad_user_data, analytics_storage.
    3. Alternatively in the Output of your tag section, select the Consent tab and check the On-page Default column.

      Screenshot of Tag Assistant showing default consent
settings

  5. Verify if the page updated the consent based on your consent banner interaction:

    1. In the Summary, select the most recent Consent event.
    2. In the API Call section, check that the following parameters were updated: ad_storage, ad_personalization, ad_user_data, analytics_storage.
    3. Alternatively in the Output of your tag section, select the Consent tab and check the On-page Update column.

      Screenshot of Tag Assistant showing updated consent
settings

Tag Manager

To verify your consent setup for websites, start a new Tag Assistant session:

  1. Open Google Tag Assistant
  2. Enter your website's URL. A new tab with your website opens.

  3. On your website, open the cookie banner and accept all.

  4. In Tag Assistant, verify if the page set the default consent correctly:

    1. In the Summary, select the earliest Consent event.
    2. In the API Call section, check that the following parameters were set: ad_storage, ad_personalization, ad_user_data, analytics_storage.
    3. Alternatively in the Output of your tag section, select the Consent tab and check the On-page Default column.

      Screenshot of Tag Assistant showing default consent
settings

  5. Verify if the page updated the consent based on your consent banner interaction:

    1. In the Summary, select the most recent Consent event.
    2. In the API Call section, check that the following parameters were updated: ad_storage, ad_personalization, ad_user_data, analytics_storage.
    3. Alternatively in the Output of your tag section, select the Consent tab and check the On-page Update column.

      Screenshot of Tag Assistant showing updated consent
settings

  6. Check which tags fired or were blocked by the consent state:

    1. In the Summary, select the Tags tab.
    2. Click a tag to check if it behaved according to the consent settings.

Select an issue to get troubleshooting instructions:

The Tag Assistant Consent tab is empty when consent mode is not implemented on the page.

To fix the issue, you need to implement consent mode. The instructions below assume that you already have a consent banner on your website.

gtag.js

Video: How to set up consent mode

gtag('consent', 'default', {
      'ad_storage': 'denied',
      'analytics_storage': 'denied',
      'ad_user_data': 'denied',
      'ad_personalization': 'denied',
});

Step by step: How to set up consent mode

If you use a consent management platform (CMP) to load a consent banner:

  1. Research if your CMP supports Google's consent mode.
  2. Check your CMP settings to activate Google consent mode.
  3. Verify consent mode works.

If you maintain your own consent banner, or your CMP doesn't automatically integrate with consent mode, implement consent mode manually.

Tag Manager

If you use Tag Manager, the recommended approach to consent mode implementation is using a consent platform that provides a Tag Manager template. To set up a consent banner using Tag Manager:

  1. Open Google Tag Manager
  2. In your workspace, open the Tags menu.
  3. Set up a New tag. Click Tag Configuration and open the Community Template Gallery.
  4. Search for your CMP provider's tag and click Add to workspace.
  5. Fill out the fields in your tag template. Your CMP provider has more information on the required fields.
  6. In Triggering, select the Consent Initialization - All Pages trigger.
  7. Save the tag and Preview your container to Verify consent mode works.

If you maintain your own consent banner, or your CMP doesn't automatically integrate with consent mode, implement consent mode manually.

Setting a consent default for all consent mode parameters helps you efficiently manage your tag behavior based on your standard consent banner implementation. Learn more about Google's consent requirements.

gtag.js

Move all code that calls gtag consent default commands higher in the page, above any tag snippets or other code that might be using consent.

Set the following consent parameters:

gtag('consent', 'default', {
      'ad_storage': 'denied',
      'analytics_storage': 'denied',
      'ad_user_data': 'denied',
      'ad_personalization': 'denied',
});

Don't set default consent states asynchronously.

Tag Manager

If you use a CMP tag template in Tag Manager, check the CMP documentation for how to set default consent using the Tag Manager template.

Make sure that the tag loads consent defaults for at least these four parameters:

  • ad_storage
  • ad_user_data
  • ad_personalization
  • analytics_storage

If you maintain your own consent banner, or your CMP doesn't automatically integrate with consent mode, implement consent mode manually.

The website needs to set the default consent state before any tags or other code uses or updates consent. Setting the default too late may not have the anticipated effect. Learn more about Google's consent requirements.

For example, in the following scenario, the Ad tag has already read or written a cookie before the default consent is set:

  1. Visitor opens page
  2. Ad tag fires
  3. Default consent set to denied

Tag Assistant reports an error: Tag Assistant
error

gtag.js

Move all code that calls gtag consent default commands higher in the page, above any tag snippets or other code that might be using consent.

Set the following consent parameters:

gtag('consent', 'default', {
      'ad_storage': 'denied',
      'analytics_storage': 'denied',
      'ad_user_data': 'denied',
      'ad_personalization': 'denied',
});

Don't set default consent states asynchronously.

Tag Manager

If a consent template tag set the default consent:

  1. Edit the trigger of the consent-writing template tag to fire on Consent Initialization.
  2. For all other tags: Fire the tags after consent was initialized. For example, to trigger a tag on page load, use the Initialization - All pages trigger.

When the website visitor interacts with your consent banner, it should send a consent update command. If the consent state doesn't update, check if you have an update mechanism implemented.

gtag.js

Use the gtag.js update command to update the consent state after a visitor interacted with your banner. Make sure that you have an update mechanism for every parameter that you set a consent default for, and that a user can update their consent to both granted and denied.

The following example shows how the function consentGrantedAdStorage updates the consent state when a visitor accepts Ads cookies in a consent banner.

<script>
function consentGrantedAdStorage() {
  gtag('consent', 'update', {
    'ad_storage': 'granted'
  });
  }
</script>
<!-- Invoke your consent function when a user interacts with your banner -->
<body>
  ...
  <button onclick="consentGrantedAdStorage()">Yes</button>
  ...
</body>

Tag Manager

If you use a consent template tag to set the default consent, make sure it also updates the consent state. Check your CMP provider documentation for more information.

You can set different consent defaults depending on the visitor region. If you have implemented consent defaults for different regions, try the following steps to verify your settings work.

gtag.js

  1. In your browser, set your visitor location to a region you want to verify. Learn how to set locations in Chrome.
  2. Verify consent mode works.
  3. If consent mode doesn't adapt to the user region, check your source code. For example:

      gtag('consent', 'default', {
        'analytics_storage': 'denied',
        'region': ['ES', 'US-AK']
      });
    
      gtag('consent', 'default', {
        'ad_storage': 'denied'
      });
    

    The example sets a regional consent default for one parameter but not the other. When you check for regional behavior, make sure that all parameters behave as directed by your organizational policies. Learn how to set up geographical regions.

Tag Manager

  1. In your browser, set your visitor location to a region you want to verify. Learn how to set locations in Chrome.
  2. Verify consent mode works.
  3. If consent mode doesn't adapt to the user region, check your consent tag's settings, see set up geographical regions.

Next steps

The Google tag is consent-aware, so it adjusts behavior based on user consent. If you are blocking the Google tag from loading until a user grants consent, your modeled conversions are less accurate, and behavioral modeling in Google Analytics 4 is unavailable. Unblock your Google tag to receive the best measurement results.

Learn more about consent mode impact results.