Consent mediation - Connect third-party SDKs

Prev Next

Consent mediation simplifies the process of signaling consent to third-party SDKs. It automatically applies consent updates to supported SDKs, helps activate Google Consent Mode, and integrates with advertising and mediation tools (even those outside TCF).

IMPORTANT

Before pushing to production, follow all steps carefully and verify consent is passed correctly.

Once correctly implemented, this feature simplifies the transmission of the consent signal and privacy choices to selected third-party SDKs.

However, it is always advisable to review and assess the documentation, privacy policy, and privacy section of third-party vendor SDKs before deciding to work with them or integrating any.

Usercentrics cannot fully guarantee the compliance of collection mechanisms of third-party vendors and SDKs.

In Unity, consent mediation operates by integrating SDKs APIs in order to stream user consent. Most Unity SDKs use a native implementation, serving as a bridge to their respective native platforms. Our approach integrates with these native libraries designed for Android and iOS. The supported SDKs listed below all utilize this integration method. If you encounter a library that doesn't follow a native implementation, please let us know by providing feedback.

Enable mediation with the following snippet:

let options = UsercentricsOptions(settingsId: <SettingsID>, consentMediation: true)
val options = UsercentricsOptions(settingsId = <SettingsID>, consentMediation = true)
Usercentrics.initialize(
    settingsId: <SettingsID>,
    consentMediation: true,
);
let options: UsercentricsOptions = { settingsId: <SettingsID>, consentMediation: true };

To enable consent mediation in Unity, expand the Options menu and mark the checkbox next to Consent Mediation.

After enabling mediation with the above, Usercentrics will apply consent automatically to all supported SDKs.

Make sure you apply consent to not supported SDKs as well.

Supported SDKs

IOS and Android supported SDKs

SDK

Supported version

Template ID

Added in

Source

Google Analytics for Firebase

21.5.0 (Android) 10.17.0 (iOS)

diWdt4yLB

2.7.0

Analytics data collection and usage

Google Analytics Advertising
for Firebase

21.5.0 (Android) 10.17.0 (iOS)

GqhZxB-iiydzEk

2.15.1

Advertising data collection and usage

Unity Ads

3.7.5 (Android) 4.2.1 (iOS)

hpb62D82I

2.7.0

Privacy consent and data APIs

AppLovin

11.4.4 (Android) 11.4.3 (iOS)

fHczTMzX8

2.7.0

Privacy-Consent and Data API for iOS and Android

ironSource

7.1.10 (Android) 7.3.0 (iOS)

9dchbL797

2.7.0

Regulation Advanced Settings for iOS and Android

Crashlytics

18.3.3 (Android) 10.4.0 (iOS)

cE0B0wy4Z

2.7.12

Privacy-Consent and Data API for iOS and Android

Adjust

5.0.0 (Android and iOS)

Jy6PlrM3

2.17.0

Privacy-Consent and Data API for iOS and Android

Chartboost

9.5.0 (Android) 9.5.1 (iOS)

IEbRp3saT

2.11.0

Privacy API for iOS and Android

Singular

12.8.0 (Android) 12.8.0 (iOS)

OxsYgtMfe7aP8u

2.21.0

Privacy-Consent and Data API for iOS and Android

AppsFlyer

6.16.2 (Android) 6.16.2 (iOS)

Gx9iMF__f

2.21.0

Privacy-Consent and Data API for iOS and Android

AirBridge

4.7.0 (Android) 4.7.0 (iOS)

1k_ljMZc28DDOc

2.22.2

Privacy-Consent and Data API for iOS and Android

Braze

32.1.0 (Android) 18.2.1 (iOS)

MMgpupdb_

2.34.0

Enable / Disable SDK API for iOS and Android

Flutter and React-Native supported SDKs

SDK

Supported version

Template ID

Added in

Source

AppLovin

3.8.1 (Flutter) 6.3.1 (React-Native)

fHczTMzX8

2.13.3

Privacy-Consent and Data API for Flutter and React-Native

ironSource

1.3.0 (Flutter) 1.1.0 (React-Native)

9dchbL797

2.13.3

Regulation Advanced Settings for Flutter and React-Native

Adjust

4.31.0 (Flutter) 4.38.0 (React-Native)

Jy6PlrM3

2.13.3

Privacy-Consent and Data API for Flutter and React-Native

Thoroughly review the documentation of each SDK to identify the APIs for accurately signaling user consent. See our implementation guidelines for each SDK mentioned above.

Some SDKs, such as Crashlytics, may automatically collect data by default. Verify whether they offer an API to disable this data collection prior to initialization.

Although most SDKs maintain consistent contracts for Privacy APIs in their updates, any changes must be noted, and the appropriate API should be used accordingly. Rigorous testing is vital for success. While our feature addresses a majority of scenarios, it is imperative that you personally verify the expected behavior in your specific use case.

Warning

Ensure that the version of the SDK in your application matches the one we currently support. In case of any doubt, double check the Integration section in the bottom of this page.

Our integration with SDKs

In this section, we provide a detailed overview of our methods for mediating consents. This initiative is part of our commitment to transparency, offering you clear insights into how we integrate with third-party SDKs to effectively signal user consent.

Google Analytics for Firebase

import FirebaseAnalytics
let consent = .granted || .denied
Analytics.setConsent([
  .analyticsStorage: consent
])
Analytics.setAnalyticsCollectionEnabled(true || false)
import com.google.firebase.ktx.Firebase
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.analytics.FirebaseAnalytics.ConsentStatus
val consent = ConsentStatus.GRANTED || ConsentStatus.DENIED
Firebase.analytics.apply {
    setConsent {
        analyticsStorage(consent)
    }
    setAnalyticsCollectionEnabled(true || false)
}

Google Analytics Advertising for Firebase

import FirebaseAnalytics
let consent = .granted || .denied
Analytics.setConsent([
  .adPersonalization: consent,
  .adStorage: consent,
  .adUserData: consent,
])
import com.google.firebase.ktx.Firebase
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.analytics.FirebaseAnalytics.ConsentStatus
val consent = ConsentStatus.GRANTED || ConsentStatus.DENIED
Firebase.analytics.setConsent {
    adPersonalization = consent
    adStorage = consent
    adUserData = consent
}

Unity Ads

import UnityAds
let key = "gdpr.consent" || "privacy.consent"
let consent = true || false
let metaData = UADSMetaData()
metaData.setRaw(key, value: consent)
metaData.commit()
import com.unity3d.ads.metadata.MetaData
val key = "gdpr.consent" || "privacy.consent"
val consent = true || false
val metaData = MetaData(context)
metaData.set(key, consent)
metaData.commit()

AppLovin

import AppLovinSDK
ALPrivacySettings.setHasUserConsent(true || false)
// or
ALPrivacySettings.setDoNotSell(true || false)
import com.applovin.sdk.AppLovinPrivacySettings
AppLovinPrivacySettings.setHasUserConsent(true || false, context)
// or
AppLovinPrivacySettings.setDoNotSell(true || false, context)

ironSource

import IronSource
IronSource.setConsent(true || false)
// or
IronSource.setMetaDataWithKey("do_not_sell", value: "NO" || "YES")
import com.ironsource.mediationsdk.IronSource
IronSource.setConsent(true || false)
// or
IronSource.setMetaData("do_not_sell", "false" || "true")

Crashlytics

import FirebaseCrashlytics
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true || false)
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
Firebase.crashlytics.setCrashlyticsCollectionEnabled(true || false)

Adjust

General consent:

import Adjust
Adjust.trackMeasurementConsent(true || false)
import com.adjust.sdk.Adjust
Adjust.trackMeasurementConsent(true || false)

Third-party SDKs:

import Adjust
let sdkName = "SDKName"
let consent = true || false
let thirdPartySharing = ADJThirdPartySharing.init(isEnabledNumberBool: nil)
thirdPartySharing.addPartnerSharingSetting(sdkName, key: "installs", value: consent)
thirdPartySharing.addPartnerSharingSetting(sdkName, key: "events", value: consent)
thirdPartySharing.addPartnerSharingSetting(sdkName, key: "sessions", value: consent)
Adjust.trackThirdPartySharing(thirdPartySharing)
import com.adjust.sdk.AdjustThirdPartySharing
val sdkName = "SDKName"
val consent = true || false
val thirdPartySharing = AdjustThirdPartySharing(null)
thirdPartySharing.addPartnerSharingSetting(sdkName, "install", consent)
thirdPartySharing.addPartnerSharingSetting(sdkName, "events", consent)
thirdPartySharing.addPartnerSharingSetting(sdkName, "sessions", consent)
Adjust.trackThirdPartySharing(thirdPartySharing)

Amazon Ads

There is no direct API call for app developers to make. Once both gating conditions are met (Amazon declared as a consented TCF vendor, Adjust configured as a DPS), the SDK builds the granular options and calls Adjust's third-party-sharing API for you, using partner name amazon_dma:

import Adjust

let adStorage = true || false
let adUserData = true || false

let amazonSharing = ADJThirdPartySharing.init(isEnabledNumberBool: nil)

amazonSharing.addGranularOption("amazon_dma", key: "ad_storage", value: adStorage ? "1" : "0")
amazonSharing.addGranularOption("amazon_dma", key: "ad_user_data", value: adUserData ? "1" : "0")

Adjust.trackThirdPartySharing(amazonSharing)
import com.adjust.sdk.AdjustThirdPartySharing

val adStorage = true || false
val adUserData = true || false

val amazonSharing = AdjustThirdPartySharing(null)

amazonSharing.addGranularOption("amazon_dma", "ad_storage", if (adStorage) "1" else "0")
amazonSharing.addGranularOption("amazon_dma", "ad_user_data", if (adUserData) "1" else "0")

Adjust.trackThirdPartySharing(amazonSharing)

Chartboost

import ChartboostSDK
let consent = true || false
let gdprConsent = consent ? CHBDataUseConsent.GDPR.Consent.behavioral : CHBDataUseConsent.GDPR.Consent.nonBehavioral
Chartboost.addDataUseConsent(CHBDataUseConsent.GDPR(gdprConsent))
Chartboost.addDataUseConsent(CHBDataUseConsent.LGPD(allowBehavioralTargeting: consent))
// or
let ccpaConsent = consent ? CHBDataUseConsent.CCPA.Consent.optInSale : CHBDataUseConsent.CCPA.Consent.optOutSale
Chartboost.addDataUseConsent(CHBDataUseConsent.CCPA(ccpaConsent))
import com.chartboost.sdk.Chartboost
import com.chartboost.sdk.privacy.model.CCPA
import com.chartboost.sdk.privacy.model.GDPR
import com.chartboost.sdk.privacy.model.LGPD
val consent = true || false
val gpdrConsent = GDPR(if (consent) GDPR.GDPR_CONSENT.BEHAVIORAL else GDPR.GDPR_CONSENT.NON_BEHAVIORAL)
Chartboost.addDataUseConsent(context, gpdrConsent)
Chartboost.addDataUseConsent(context, LGPD(consent))
// or
val ccpaConsent = if (consent) CCPA.CCPA_CONSENT.OPT_IN_SALE else CCPA.CCPA_CONSENT.OPT_OUT_SALE
Chartboost.addDataUseConsent(context, CCPA(ccpaConsent))

Singular

import com.singular.sdk.Singular
val consent = true || false
Singular.limitDataSharing(!consent)
if (consent) {
    Singular.resumeAllTracking()
    Singular.trackingOptIn()
} else {
    Singular.stopAllTracking()
}
import com.chartboost.sdk.Chartboost
import com.chartboost.sdk.privacy.model.CCPA
import com.chartboost.sdk.privacy.model.GDPR
import com.chartboost.sdk.privacy.model.LGPD
val consent = true || false
val gpdrConsent = GDPR(if (consent) GDPR.GDPR_CONSENT.BEHAVIORAL else GDPR.GDPR_CONSENT.NON_BEHAVIORAL)
Chartboost.addDataUseConsent(context, gpdrConsent)
Chartboost.addDataUseConsent(context, LGPD(consent))
// or
val ccpaConsent = if (consent) CCPA.CCPA_CONSENT.OPT_IN_SALE else CCPA.CCPA_CONSENT.OPT_OUT_SALE
Chartboost.addDataUseConsent(context, CCPA(ccpaConsent))

AppsFlyer

import com.appsflyer.AppsFlyerLib
let consent = true || false
switch variant {
case .TCF:
  AppsFlyerLib.shared().enableTCFDataCollection(true)
case .GDPR:
  let gdprUser = AppsFlyerConsent(
    isUserSubjectToGDPR: true,
    hasConsentForDataUsage: consent,
    hasConsentForAdsPersonalization: consent,
    hasConsentForAdStorage: consent
  )
  AppsFlyerLib.shared().setConsentData(gdprUser)
case .CCPA: 
  let nonGdprUser = AppsFlyerConsent(
    isUserSubjectToGDPR: false,
    hasConsentForDataUsage: consent,
    hasConsentForAdsPersonalization: consent,
    hasConsentForAdStorage: consent
  )
  AppsFlyerLib.shared().setConsentData(nonGdprUser)
}
import com.appsflyer.AppsFlyerConsent
import com.appsflyer.AppsFlyerLib
val consent = true || false
when (variant) {
    TCF -> {
        AppsFlyerLib.getInstance().enableTCFDataCollection(true)
    }
    GDPR -> {
        val gdprUser = AppsFlyerConsent(
            isUserSubjectToGDPR = true,
            hasConsentForDataUsage = consent,
            hasConsentForAdsPersonalization = consent,
            hasConsentForAdStorage = consent
            )
        AppsFlyerLib.getInstance().setConsentData(gdprUser)
    }
    CCPA -> {
        val nonGdprUser = AppsFlyerConsent(
            isUserSubjectToGDPR = false,
            hasConsentForDataUsage = consent,
            hasConsentForAdsPersonalization = consent,
            hasConsentForAdStorage = consent
        )
        AppsFlyerLib.getInstance().setConsentData(nonGdprUser)
    }
}

AirBridge

import airbridge-ios-sdk
let consent = true || false
if consent {
    AirBridge.startTracking()
} else {
    AirBridge.stopTracking()
}
import co.ab180.airbridge.Airbridge
val consent = true || false
if (consent) {
    Airbridge.startTracking()
} else {
    Airbridge.stopTracking()
}

Braze

Braze has a single on/off switch for the whole SDK, so the consent decision for the Braze service turns all of Braze on or off, including analytics, push notifications, in-app messages and content cards. When the user accepts the Braze service, Braze is enabled. When the user denies it, Braze is disabled. For CCPA, Braze stays enabled until the user opts out. Braze remembers the disabled state between app launches, and we apply the stored decision again on every launch. The Braze versions in the Supported SDKs table are the ones we build and test against. We also ran the integration with Braze Android 43.1.1.

Android works automatically. On iOS you register a small handler that switches your own Braze instance, because the iOS Braze SDK has no global switch that we can reach.

import BrazeKit
import Usercentrics

// Create your Braze instance as usual, then register the handler once it exists.
// Use a weak reference so Usercentrics does not keep Braze alive.
UsercentricsCore.setBrazeConsentHandler { [weak braze] allowed in
    braze?.enabled = allowed.boolValue
}
import com.braze.Braze

val consent = true || false

if (consent) {
    Braze.enableSdk(context)
} else {
    Braze.disableSdk(context)
}

Android needs no code

The Kotlin snippet shows what the SDK does for you. You only need Braze in your app and the Braze service in your configuration.

Setup

  1. Add Braze as a service in your configuration and make sure its Template ID matches the one in the Supported SDKs table.

  2. Enable Consent Mediation (see "Enable consent mediation" on this page).

  3. On iOS, register the handler shown above.

If Consent Mediation is off, or the Braze service is not in your configuration, nothing is called and Braze is not changed.

Good to know for iOS

  • Register the handler after the Braze instance exists. When you register, Usercentrics immediately delivers the latest decision if there is one, so a decision made earlier is not lost.

  • The handler runs on the main thread. Keep it light.

  • Capture braze weakly, as in the snippet.

  • Register a handler only once per app. Registering again replaces the previous one, and passing nil removes it.

  • If no handler is registered, Braze is not changed, the SDK logs one warning, and the consent mediation result reports Braze as not mediated. The decision is still delivered as soon as you register a handler.

  • Braze 19 and newer needs iOS 15 or later.

Start Braze disabled

A new user is not tracked before they choose if Braze starts disabled. Create the Braze instance with braze.enabled = false (iOS) or call Braze.disableSdk(context) before Braze starts (Android). Usercentrics then enables Braze when the user accepts. Without this, Braze is on for a short time at startup, until the stored decision is applied.

Flutter, React-Native and Unity

The Android part works the same way and needs no code. On iOS, register the handler in your native code.

  • Flutter: in AppDelegate, right after the Braze plugin has created its instance.

  • React-Native:

    • iOS: register the handler in the place where you create Braze, for example BrazeReactInitializer's post-initialization step, not at app launch. If the handler is registered before Braze exists, the first decision is lost.

    • Android: call Braze.initialize before Usercentrics.configure. Braze.initialize always switches Braze on again. If it runs after the stored decision was applied, Braze is ON although the user denied.

  • Unity: see Braze on the Games page for the iOS and Android setup.

Denying Braze consent turns off all of Braze, not only some of its features. Make sure this is what you want for the service in your configuration.

Limitations

  • Denying the Braze service turns off all of Braze, as described above.

  • clearUserSession runs Consent Mediation again, so Braze is switched on or off according to the decision that applies after the reset.

  • Not tested: tvOS, real devices, and release builds with R8 minification in the Flutter, React-Native and Unity apps.

Troubleshooting

  • To confirm it works, turn on the debug logger level and look for [Mediation] Applied Braze - Consent is TRUE or FALSE.

  • On Android, if Braze is not in your app, Braze is reported as not mediated and nothing is changed.

  • On iOS, if no handler is registered, the SDK logs a warning and Braze is reported as not mediated.

Supported mediation SDKs

These SDKs mediate consent for selected SDKs themselves. Make sure you set up the correct TemplateIDs to automatically pass consent to mediated SDKs.

Adjust

Check out Adjust's documentation page to get an insight on the Partners API. Note that we only support the ones listed below.

SDK

Template ID

Apple Ads

weoN4Lb_MjWLuu

Facebook

ocv9HNX_g

Google Ads

S1_9Vsuj-Q

Google Marketing Platform

t-TPeXsRi

Snapchat

QcD9GVNXZ

Tencent

tMLzMavbHZoxW0

TikTokSan

6-qobRfu

Twitter

Skj79NodobQ

Yahoo Gemini

HJSPc4ids-Q

Yahoo Japan Search

gUbemZYaQwqxss

Unlike the partners listed above, Amazon Ads is not selected via a Template ID override. There is no native Amazon SDK bridged into Usercentrics — instead, the signal is forwarded through Adjust's granular third-party-sharing API (partner name amazon_dma) automatically whenever both of the following are true:

  • Amazon (IAB TCF vendor ID 793, "Amazon.com Services, Inc.") is a declared, consented vendor in your configuration

  • Adjust itself is configured as a Data Processing Service (DPS) for your tenant (Template ID Jy6PlrM3)

When both conditions are met, the SDK derives a granular consent object from the TCF purposes and signals it to Adjust:

Amazon granular flag

Derived from TCF purpose(s)

ad_storage

Purpose 1

ad_user_data

Purposes 1 and 7

This mirrors the existing Google Consent Mode signal (vendor 755), except Amazon does not use ad_personalization or eea flags. Added in version 2.29.1.

Info

There is no amazonAdsTemplateId (or similar) override on UsercentricsMediation.Adjust — the vendor ID is fixed and not configurable, unlike the other Adjust-mediated partners above.

Custom DPS

When creating a Custom DPS, its Template ID will be new and unique. For this reason, if you want to use Consent Mediation, you need to modify the default Template ID we provide in the tables above. you will need to provide this information to our SDK for Consent Mediation to know how to match your Custom DPS with the SDK you are passing consent.

Warning

The setup below must always happen before Usercentrics is initialized.

To do this, we have provided the object UsercentricsMediation. For example if you want to switch the TemplateID for Unity Ads:

UsercentricsMediation.shared.unityAdsTemplateId = "CustomTemplateId"
UsercentricsMediation.unityAdsTemplateId = "CustomTemplateId"

You can customize the Template ID for SDKs that are mediated by supported SDKs. For example, SDKs that are mediated by Adjust:

UsercentricsMediation.Adjust.shared.snapchatTemplateId = "CustomTemplateId"
UsercentricsMediation.Adjust.snapchatTemplateId = "CustomTemplateId"

Debugging

Debug mode

To see debug messages, please set the SDK's loggerLevel to DEBUG.

When running your application with Consent Mediation enabled, you should expect the following events:

Enable confirmation

Immediately after initialization, you will get a confirmation that consent mediation is enabled:

[USERCENTRICS] Consent Mediation is Enabled

Scan

After your configuration has been loaded, the SDK will provide an overview of the supported services:

[USERCENTRICS][Mediation] 2/6 Services are supported: Unity Ads | Google Analytics for Firebase

Mediation

Whenever a user provides consent or the SDK has been initialized, the SDK will apply the latest user choices to each supported SDK:

[USERCENTRICS][Mediation] ✅ Google Analytics for Firebase: TRUE
[USERCENTRICS][Mediation] ✅ Unity Ads: FALSE

Default consent

On first launch, you will see consent is applied immediately after initialization, even when a user still has not given consent. This happens because the default consent provided in your configuration is being applied.

Warning

If your workflow necessitates the simultaneous initialization of certain SDKs alongside Usercentrics, be aware of potential racing conditions.

These can arise when the mediation routine is executed while an SDK is still in the process of initialization. To mitigate such issues, we strongly advise initializing SDKs only after obtaining user consent. For more detailed guidance on this approach, refer to our further recommendations here.