Didomi - Developers documentation
  • Introduction
  • SDKs
    • Introduction
    • Web SDK
      • Getting started
      • Tags and vendors management
        • Tags management
          • Events & Variables
            • Deprecated
            • Custom events
          • Tag managers
            • Adobe Launch/DTM
            • Eulerian
            • Google Tag Manager
              • Configure the Didomi / GTM integration
              • Didomi's GTM template
            • Tealium
            • Other tag managers
        • Custom Didomi <script> tags
        • Third-party integrations
          • Google Ad Manager / AdSense
            • GDPR via Non-Personalized Ads
              • Share consent and load/refresh ads
              • Share consent without loading or refreshing ads
            • US states laws
          • Google Consent Mode V2
          • Kameleoon
          • Piano Analytics (AT Internet)
          • Prebid
            • GDPR via IAB TCF
            • US states laws
          • Salesforce DMP (Krux)
        • IAB frameworks
        • Programmatic API
      • Configuration
        • Bots (SEO & Performance tools)
        • Configuration by URL
        • Cookies and storage
        • Custom domains for events
        • Notice
          • Behavior
          • Interactions
          • Look and feel
        • Preferences
        • Theme
      • AB tests
      • Custom domain
        • Domain delegation
        • Reverse proxy
      • Share consents between domains
      • Share consents across devices
      • Pass user choices in query string
      • Serve Didomi assets from your domain
      • Reference
        • API
          • Deprecated
        • Events
      • Performance
      • Versions
    • Mobile and TV SDKs
      • Android and Android TV
        • Setup
        • Logging
        • Reference
          • API
            • Deprecated
          • Events
        • Versions
      • iOS and tvOS
        • Setup
        • Logging
        • App Tracking Transparency (iOS 14.5+)
        • Reference
          • API
            • Deprecated
          • Events
        • Versions
      • Unity
        • Setup
        • Reference
        • Versions
        • Troubleshooting
      • React Native
        • Setup
        • Reference
          • Deprecated
        • Versions
      • Flutter
        • Setup
        • Reference
        • Versions
      • Consent notice
        • Getting started
        • Customize the notice
        • Customize the preferences popup
        • Customize the theme & UI
        • Load notice by ID
      • Third-party SDKs
      • Share consents across devices
      • Share consent with WebViews
      • Google Consent Mode v2
      • FAQ
    • AMP SDK
      • Blocking Behaviors
        • Load immediately on page load
        • Load only after consent (positive or negative)
        • Load only after positive consent
      • Consent status for vendors
    • Help & Support
  • API
    • Introduction
      • Authentication
      • Errors
      • Pagination
      • Filters
      • Caching
      • Rate limiting
      • Quotas
      • Translations
    • Data Manager
      • Regulations
      • Configuration Tree
      • Purposes
        • Purposes & Vendors Numerical IDs
      • Preferences Library
      • User Rights
    • Widgets
      • Consent notices
        • Notices
        • Configurations
        • Multi-Regulation Configurations
          • Migration of Existing Notices and API Updates
        • Deployments
        • Tutorials
          • Create and publish a consent notice
          • Create and publish a multi-regulation consent notice
      • Privacy widgets
        • Create a widget
        • Retrieve widgets
        • Edit a widget
          • Content & Design
            • Themes & Shapes
            • Components
              • auth
              • dsar_form
              • footer
              • header
              • preference
              • preference_value
              • save
              • section
              • sections
            • Options
          • Purposes & preferences
          • Settings
        • Deploy a Widget
          • Use your own subdomain
          • Use your own domain
          • Implement an embeddable widget on your website
        • Authentication
          • Manage authentication providers
          • Authenticate your end-user
        • Archive a widget
        • Headless widgets
          • Public Methods
          • Custom elements
          • Custom events
          • Event listeners
        • Tutorial
          • Launch a Preference Center from a mobile app
    • Compliance Reports
      • Properties
      • Reports
      • CSV format reference
      • Websites
    • Consents and Preferences
      • Events
        • Generate IAB TCF consent string
      • Links
      • Proofs
      • Tokens
      • Secrets
      • Users
      • Tutorial
        • Collect and operate data
    • Privacy Requests
      • Requests
      • Notes
      • Links
      • Emails
  • Integrations
    • Introduction
      • Quotas
    • Generic integrations
      • Batch export
        • Destinations
          • AWS S3 Bucket (owned by Didomi)
          • GCP Storage Bucket
        • Exported data
          • Notices consents
        • Logs
      • Webhooks
      • Batch import
      • Analytics export
        • Destinations
          • AWS S3 Bucket (owned by Didomi)
          • GCP Storage Bucket
    • Third-party apps
      • CMP integrations
        • Didomi-mParticle integration for your CMP
        • Deploy Didomi’s SDK for your Adobe Commerce website
      • Preference Management Platform integrations
        • Actito
        • Adobe Campaign Classic
        • Adobe Experience Cloud
        • Adobe Marketo Engage
        • Adobe Source Connector
        • Braze
        • Dotdigital
        • Hubspot
        • Mailchimp
        • Microsoft Dynamics 365
        • Salesforce Marketing Cloud
        • Salesforce Sales & Service Cloud
        • Selligent
        • Brevo (ex Sendinblue)
    • Tutorials
      • Configure a HTTP webhook
      • Configure a batch export
      • Configure an analytics export
    • Emailing
      • Configurations
        • Actito Email
        • Actito SMS
        • Adobe Campaign Classic
        • Adobe Campaign Standard
      • Emails
        • Templates
        • Manage your templates
Powered by GitBook
On this page
  • Initial setup
  • Analytics storage
  • Ad storage
  • Ad user data
  • Ad personalization
  • Update consent
  • Get and apply user consent for Google
  • Enabling Consent mode's TCF integration
  1. SDKs
  2. Mobile and TV SDKs

Google Consent Mode v2

PreviousShare consent with WebViewsNextFAQ

Last updated 10 months ago

Google Analytics offers Consent Mode v2 to adjust how your SDK behaves based on the consent status of your users. You can indicate whether consent has been granted for Analytics and Ads cookies. To implement Consent Mode v2 for apps, use the Google Analytics for Firebase SDK to set default consent values and use the setConsent method to update these values programmatically, based on in-app user consent. To learn more, see .

Google Consent Mode allows you to configure the status for the following parameters or Consent Types:

  • ANALYTICS_STORAGE

  • AD_STORAGE

  • AD_USER_DATA

  • AD_PERSONALIZATION

Initial setup

By default, no Consent Type values are set. Follow the instructions below to change the default consent state for your app.

Analytics storage

To disable Analytics storage, set the value of google_analytics_default_allow_analytics_storage to false in the application tag of your app's AndroidManifest.xml file. For example:

<meta-data android:name="google_analytics_default_allow_analytics_storage" android:value="false" />

To disable Analytics storage, set the value of GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE to NO in your app's Info.plist file:

<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE</key>
<false/>

Ad storage

To disable Ad storage, set the value of google_analytics_default_allow_ad_storage to false in the application tag of your app's AndroidManifest.xml file. For example:

<meta-data android:name="google_analytics_default_allow_ad_storage" android:value="false" />

To disable Ad storage, set the value of GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE to NO in your app's Info.plist file:

<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE</key>
<false/>

Ad user data

To disable Ad user data, set the value of google_analytics_default_allow_ad_user_data to false in the application tag of your app's AndroidManifest.xml file. For example:

<meta-data android:name="google_analytics_default_allow_ad_user_data" android:value="false" />

To disable Ad user data, set the value of GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA to NO in your app's Info.plist file:

<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA</key>
<false/>

Ad personalization

To disable Ad personalization, set the value of google_analytics_default_allow_ad_personalization_signals to false in the application tag of your app's AndroidManifest.xml file. For example:

<meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="false" />

To disable Ad personalization, set the value of GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS to NO in your app's Info.plist file:

<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS</key>
<false/>

Update consent

To update the Consent Type values after an app has launched, call the setConsent method of the Analytics library.

The value set by the setConsent method persists across app executions and overrides the default values configured through the Info.plist and AndroidManifest.xml files . The value remains in that state until setConsent is called again, even if a user closes and reopens the app. Calling setConsent to modify Ad storage does not change the state of Analytics storage or any other consent mode value.

The following example shows the setConsent method updating values for Analytics, Ad storage, Ad user data and Ad personalization to granted or denied:

// Set consent types.
Map<ConsentType, ConsentSetting> consentMap = new EnumMap<>(ConsentType.class);
consentMap.put(ConsentType.ANALYTICS_STORAGE, ConsentStatus.GRANTED|ConsentStatus.DENIED);
consentMap.put(ConsentType.AD_STORAGE, ConsentStatus.GRANTED|ConsentStatus.DENIED);
consentMap.put(ConsentType.AD_USER_DATA, ConsentStatus.GRANTED|ConsentStatus.DENIED);
consentMap.put(ConsentType.AD_PERSONALIZATION, ConsentStatus.GRANTED|ConsentStatus.DENIED);

mFirebaseAnalytics.setConsent(consentMap);
Firebase.analytics.setConsent {
    analyticsStorage = ConsentStatus.GRANTED|ConsentStatus.DENIED
    adStorage = ConsentStatus.GRANTED|ConsentStatus.DENIED
    adUserData = ConsentStatus.GRANTED|ConsentStatus.DENIED
    adPersonalization = ConsentStatus.GRANTED|ConsentStatus.DENIED
}
Analytics.setConsent([
  .analyticsStorage: .granted|.denied,
  .adStorage: .granted|.denied,
  .adUserData: .granted|.denied,
  .adPersonalization: .granted|.denied,
])
[FIRAnalytics setConsent:@{
  FIRConsentTypeAnalyticsStorage : FIRConsentStatusGranted|FIRConsentStatusDenied,
  FIRConsentTypeAdStorage : FIRConsentStatusGranted|FIRConsentStatusDenied,
  FIRConsentTypeAdUserData : FIRConsentStatusGranted|FIRConsentStatusDenied,
  FIRConsentTypeAdPersonalization : FIRConsentStatusGranted|FIRConsentStatusDenied,
}];

Get and apply user consent for Google

The status of Google Vendor with ID google will be used to get the value for:

  • AD_STORAGE

  • AD_USER_DATA

  • AD_PERSONALIZATION

The status of Google Analytics Vendor with ID c:googleana-4TXnJigR will be used to get the value for:

  • ANALYTICS_STORAGE

The following examples show how to get the user status from the Didomi SDK and apply that status to Google Consent Mode.

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void consentChanged(ConsentChangedEvent event) {
        // The status of the user has changed
        UserStatus userStatus = Didomi.getInstance().getUserStatus();
        
        // Ids of enabled vendors
        Set<String> enabledVendorIds = userStatus.getVendors().getGlobal().getEnabled();
        
        // Search for Google vendors
        ConsentStatus googleAnalyticsStatus = enabledVendorIds.contains("c:googleana-4TXnJigR") ? ConsentStatus.GRANTED : ConsentStatus.DENIED
        ConsentStatus googleStatus = enabledVendorIds.contains("google") ? ConsentStatus.GRANTED : ConsentStatus.DENIED
        
        // Set consent types
        Map<ConsentType, ConsentSetting> consentMap = new EnumMap<>(ConsentType.class);
        consentMap.put(ConsentType.ANALYTICS_STORAGE, googleAnalyticsStatus);
        consentMap.put(ConsentType.AD_STORAGE, googleStatus);
        consentMap.put(ConsentType.AD_USER_DATA, googleStatus);
        consentMap.put(ConsentType.AD_PERSONALIZATION, googleStatus);
        
        mFirebaseAnalytics.setConsent(consentMap);
    }
})
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun consentChanged(event: ConsentChangedEvent) {
        // The status of the user has changed
        val userStatus = Didomi.getInstance().userStatus
        
        // Ids of enabled vendors
        val enabledVendorIds = userStatus.vendors.global.enabled
        
        // Search for Google vendors
        val googleAnalyticsStatus = if (enabledVendorIds.contains("c:googleana-4TXnJigR")) ConsentStatus.GRANTED else ConsentStatus.DENIED
        val googleStatus = if (enabledVendorIds.contains("google")) ConsentStatus.GRANTED else ConsentStatus.DENIED
        
        // Set consent types
        Firebase.analytics.setConsent {
            analyticsStorage = googleAnalyticsStatus
            adStorage = googleStatus
            adUserData = googleStatus
            adPersonalization = googleStatus
        }
    }
})
let didomiEventListener = EventListener()
didomiEventListener.onConsentChanged = { event in
    // The status of the user has changed
    let userStatus = Didomi.shared.getUserStatus()
    
    // Ids of enabled vendors
    let enabledVendorIDs = userStatus.vendors.global.enabled
    
    // Search for Google vendors
    let googleAnalyticsStatus: FirebaseAnalytics.ConsentStatus = enabledVendorIDs.contains("c:googleana-4TXnJigR") ? .granted : .denied
    let googleStatus: FirebaseAnalytics.ConsentStatus = enabledVendorIDs.contains("google") ? .granted : .denied
    
    // Set consent types
    Analytics.setConsent([
      .analyticsStorage: googleAnalyticsStatus,
      .adStorage: googleStatus,
      .adUserData: googleStatus,
      .adPersonalization: googleStatus
    ])
}
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnConsentChanged:^(enum DDMEventType event) {
    // The status of the user has changed
    Didomi *didomi = [Didomi shared];
    DDMUserStatus *userStatus = [didomi getUserStatus];
    
    // Ids of enabled vendors
    NSSet *enabledVendorIDs = [[[userStatus vendors] global] enabled];
    
    // Search for Google vendors
    FIRConsentType googleAnalyticsStatus = [enabledVendorIDs containsObject:@"c:googleana-4TXnJigR"] ? FIRConsentStatusGranted : FIRConsentStatusDenied;
    FIRConsentType googleStatus = [enabledVendorIDs containsObject:@"google"] ? FIRConsentStatusGranted : FIRConsentStatusDenied;
    
    // Set consent types
    [FIRAnalytics setConsent:@{
      FIRConsentTypeAnalyticsStorage : googleAnalyticsStatus,
      FIRConsentTypeAdStorage : googleStatus,
      FIRConsentTypeAdUserData : googleStatus,
      FIRConsentTypeAdPersonalization : googleStatus
    }];
}];

Enabling Consent mode's TCF integration

  • Consent mode's TCF integration is only valid when you use both TCF integration and Google's Consent mode.

  • It is only valid for advertising consent types: ad_storage ad_user_data and ad_personalization.

  • It does not apply to analytics_storage.

  • As of now, ad_user_data is only compatible with IAB purpose 7 (“Measure advertising performance”) being used in consent legal basis for the Vendor Google Advertising Products.

To enable this integration:

  1. Login to the Didomi Console.

  2. Go to Consent notices and select your Mobile App consent notice.

  3. Navigate to Customization -> Integrations -> Advertising.

  4. Make sure the Consent mode integration checkbox is selected.

  5. Select the option "Enable IAB TCF integration with Google Consent Mode". Click on Save.

  6. Add the publisher restriction for IAB Purpose #7 on the Vendor Google Advertising Products. To do so:

    1. Navigate to Regulations -> GDPR -> Edit vendors & purposes

    2. Go to TCF settings -> IAB TCF Publisher Restrictions

    3. Click "Add restriction"

    4. Choose purpose "Measure advertising performance"

    5. Un-select "All IAB vendors".

  7. Publish your notice.

    • ad_storage

    • ad_user_data

    • ad_personalization

As a result:

  • When user consent is collected on your CMP, the Didomi SDK will setup the IABTCF_EnableAdvertiserConsentMode key on NSUserDefaults (iOS) and Shared Preferences (Android) to true .

To update the Consent Type values after a user has provided their consent choices, use the method of the Analytics library as shown in the examples below.

You can optionally enable Consent mode's TCF integration which will allow setting consent mode status from the user’s choice in the .

Select "Google Advertising Products" vendor.

Scroll down to Restriction and choose "Require consent for selected vendors".

In the code of your Mobile app make sure you do not for the following consent types:

Make sure is still done for analytics_storage.

Consent mode status for ad_storage ad_user_data and ad_personalization will then be calculated from the status of TCF purposes in the TC string, as defined in .

analytics_storage is not impacted by Consent mode's TCF integration, and must be covered by as documented above.

Consent Mode
setConsent
TC string
this documentation
setConsent
setConsent
setConsent