Share consent without loading or refreshing ads

Our integration with Google Ad Manager which relies on passing an NPA parameter to ad requests is still available in the Didomi Console. But we do not advise using it. Please review our Google Ad Manager implementation recommendation here. This module does not support automatically passing CCPA Do Not Sell Status to Google products yet. See https://support.google.com/adsense/answer/9598414 for more information.

Didomi supports sharing consent with Google Ad Manager, AdSense and Ad Exchange asynchronous ad tags. When the user gives consent, the Google tags are configured to fetch personalized ads.

With this integration, Didomi shares consent with Google Ad Manager/AdSense but does not load or refresh ads. This allows you to fully control the ad workflow on your pages and build more complex use cases like include Prebid auction results into your Ad Manager ad slots, for instance.

For this integration to work, you need to make sure that you are delaying the loading of Google ads until Didomi has shared the consent information with Google. You must also synchronize the ad calls to ensure that consent is passed before the ads are loaded on the page.

Configure the Didomi tag

If you are using the Didomi Console to manage your consent notices, you can manage the Google integration from there and can skip this tag configuration section.

You must ensure that the Didomi tag gets embedded first on your pages and configure it to communicate with the Google tag.

Enable the Didomi / Google integration

Make sure that you add the following vendors to your tag (in the app.vendors property):

  • googleas a Didomi vendor (app.vendors.didomi property)

  • All the "ad technology providers" enabled in your Google account (see the Google Ad Manager documentation or the Google AdSense documentation). They can be added as IAB vendors (recommended if they are in the list), Didomi or custom vendors, and must appear in the list for the consent to be valid.

You also need to enable the specific integration with Google with the property integrations:

<script type="text/javascript">
window.didomiConfig = {
  app: {
    apiKey: '<Your API key>',
    vendors: {
      iab: {
        include: [
          ..., // All the vendors that you have enabled as ad technology providers in your Google account
        ]
      },
      didomi: [
        // Ask Didomi to collect consent for Google
        'google'
      ]
    }
  },
  
  integrations: {
    vendors: {
      // Setup the integration with Google (ask Didomi to share consent with Google tags)
      google: {
        enable: true,
        refresh: false // Tell the SDK to never load/refresh ads and only share consent with Google
      }
    }
  }
};
</script>

This configuration will tell the Didomi tag to automatically share consent with Google and never load or refresh ads (ie the Didomi SDK will never call window.googletag.pubads().refresh() ).

integrations.google is required

It is used to tell the Didomi SDK to enable the integration with the Google tag. If you do not add that object, consent will be collected for Google but will not be shared with their tag.

According to Google's documentation and to be compliant with the ePrivacy directive from 2002/2009, even when configured to serve non-personalized, their tags still use cookies for "frequency capping, aggregated ad reporting, and to combat fraud and abuse".

As a result, no ad request should be sent to Google (and no ad displayed) until the user has given consent for the cookies purpose. This is the recommended behavior. The Didomi SDK will always share the consent status with Google and you are in charge of deciding when ads should actually be displayed.

The Didomi SDK supports Google's additional consent mode.

It allows collecting consents for Google Ad vendors which are currently not part of the IAB TCF but are part of Google's Ad Tech Providers list (ATP).

Additional consent string format

The additional consent string contains 4 parts:

  • A specification version number, such as "2"

  • A separator symbol "~"

  • A dot-separated list of user-consented Google Ad Tech Provider (ATP) IDs. Example: "1.35.41.101"

  • A separator symbol "~"

  • "dv." followed by a dot-separated list of disclosed Google Ad Tech Provider (ATP) IDs. Example: "dv.9.21.81"

For example, the AC string 2~1.35.41.101~dv.9.21.81 means that the user has consented to ATPs with IDs 1, 35, 41 and 101, ATPs with IDs 9, 21, and 81 have been disclosed to the user and the string is created using the format defined in the v2 specification.

You can find the latest Google's Ad Tech Providers (ATP) list here.

Configure your Google account

Whether you are using Ad Manager or AdSense, your need to configure your account to allow personalized ads.

Ad Manager account configuration

Sign into Google Ad Manager, go to Admin EU user consent and ensure that your account is setup for serving personalized ads (see instructions from Google on https://support.google.com/dfp_premium/answer/7673898).

The Didomi CMP will take care of enabling personalized or non-personalized ads on a per-request basis but your account must be configured to allow serving personalized ads. Otherwise, only non-personalized ads will be served no matter what the consent status of the user is.

Also not that you must identify all the vendors used by Google for serving ads and add them to your Didomi tag configuration to make sure that consent is collected for everyone of them.

AdSense account configuration

Sign into Google AdSense, go to Allow & block ads Content All my sites EU user consent and ensure that your account is setup for serving personalized ads (see instructions from Google on https://support.google.com/adsense/answer/7670013).

The Didomi CMP will take care of enabling personalized or non-personalized ads on a per-request basis but your account must be configured to allow serving personalized ads. Otherwise, only non-personalized ads will be served no matter what the consent status of the user is.

Also not that you must identify all the vendors used by Google for serving ads and add them to your Didomi tag configuration to make sure that consent is collected for everyone of them.

Configure Google tags for loading and refreshing ads

The Didomi SDK will automatically share the user consent status with Google and you must ensure that ads do not get loaded before Didomi has done so.

The SDK exposes the event integrations.consentpassedtodfp to be notified when the user consent status has been shared with Google. Once that is done, you can resume your ad operations and load or refresh your ads as needed:

/**
 * Add an event listener to get notified once Didomi has passed
 * the user consent status to Google
 * Important: this must be placed before the Didomi SDK gets embedded on your
 * website to guarantee that you do not miss any event
 */
window.didomiEventListeners = window.didomiEventListeners || [];
window.didomiEventListeners.push({
  event: 'integrations.consentpassedtodfp',
  listener: function (data) {
    // Consent has been passed to Google
    // Load or refresh ads as needed with Ad Manager, Prebid, etc.
    // `data.consentStatus` contains the current consent status of the user (true/false/undefined)
    // `data.index` contains the index of the event (integer)
    if (data.index === 0) {
      // This is the very first event on the page that gets triggered on page load
    } else {
      // This is an event that happens later on the page, after a user action (user giving consent or changing their preferences)
    }
  }
});

The integrations.consentpassedtodfp event is triggered every time the user consent status changes and can be called multiple times on a single page. For instance, the very first time a user visits your website, this event will be called twice on the page: once with an undefined consent status (and index 0) and a second time, after the user has given consent, with a true consent status (and index 1).

The data object provided to your listener contains the current user consent status for Google as well as the index of the event so that you can decide to only react to some consent statuses. The index is the number of the event on the page. There is always a first event that gets triggered with index 0 on page load. More events can be triggered if the user changes their consent preferences on the page and the index gets incremented by 1 for every event triggered.

The cases that commonly need to be taken into account when deciding to load or refresh ads are the following:

Consent statusIndexCase

true / false

0

User visits a page and has already made a consent choice on a previous page so that the consent status is immediately available.

undefined

0

User visits your website for the first time and has not made a consent choice yet.

true / false

>0

User is on the page and has made a new consent choice.

Fast loading of ads outside of the EU (if you are not an EU company)

If you want to optimize your ad delivery, you can decide not to delay the loading of ads when the user is outside of the EU and not rely on Didomi for that. If your company is based in the EU then you must apply GDPR to all visitors and cannot leverage this option.

Ad Manager macros

Didomi can pass the IAB consent string and the GDPR status to Ad Manager as page-level custom targeting variables. These variables can be used in creative snippets with pattern match macros to pass the IAB consent string to creatives/vendors served through Ad Manager creatives.

Configuration

Console

If you manage your consent notices through the Didomi Console, make sure to enable the "Pass IAB consent string and GDPR status as targeting variables to creatives" option for the Google Ad Manager integration.

Tag

If you manage the Didomi tags yourself, set the integrations.vendors.google.passTargetingVariables to true to configure the SDK to pass targeting variables to Ad Manager.

<script type="text/javascript">
window.didomiConfig = {
  app: {
    apiKey: '<Your API key>',
    vendors: {
      iab: {
        include: [
          ..., // All the vendors that you have enabled as ad technology providers in your Google account
        ]
      },
      didomi: [
        // Ask Didomi to collect consent for Google
        'google'
      ]
    }
  },
  
  integrations: {
    vendors: {
      // Setup the integration with Google (ask Didomi to share consent with Google tags)
      google: {
        enable: true,
        eprivacy: true,
        passTargetingVariables: true
      }
    },
  }
};
</script>

Variables

The Didomi SDK pushes the following variables:

Variable nameDescriptionMacro

iabconsentstring

Current IAB consent string of the user

%%PATTERN:iabconsentstring%%

iabgdprapplies

Whether the GDPR applies to the current user (0 = No / 1 = Yes)

%%PATTERN:iabgdprapplies%%

Macros in creatives

You can use pattern match macros to pass the IAB consent string and GDPR status to a creative.

Example:

The creative code

https://vendor.com/creative?gdpr_consentstring=%%PATTERN:iabconsentstring%%&gdpr_status=%%PATTERN:iabgdprapplies%%

will be rendered as the following code when the creative gets served

https://vendor.com/creative?gdpr_consentstring=SWFtYWNvbnNlbnRzdHJpbmc=gdpr_status=1

Last updated