Google Consent Mode v2 Support for inApp SDKs
Looking for a CMP that supports Google Consent Mode? See our Google Consent Mode v2 product page.
This guide provides instructions on how to integrate Google Consent Mode with the custom ConsentManager in your Android or iOS application.
Prerequisites
- Ensure Consent Mode is enabled (Menu > CMPs > Integrations > Google Consent Mode)
- Ensure Google Analytics, Google Ads or the other Google services are in your vendorlist
- A Firebase project with Google Analytics enabled.
- Firebase SDK integrated into your iOS project.
-
CMPManager
set up in your project.
Overview
Below you'll find helper methods that will allow you to retrieve and manage Google Consent Status using our CMP SDK.
iOS
let consentModeStrings = CMPManager.shared.getGoogleConsentModeStatus()
var firebaseConsentSettings: [ConsentType: ConsentStatus] = [:]
for (keyString, valueString) in consentModeStrings {
let consentType = ConsentType(rawValue: keyString)
let consentStatus = valueString == "granted" ? ConsentStatus.granted : ConsentStatus.denied
firebaseConsentSettings[consentType] = consentStatus
}
Analytics.setConsent(firebaseConsentSettings)
Android
val consentModeStrings = getGoogleConsentModeStatus(cmpManager)
val analyticsParams = mutableMapOf<String, String>()
consentModeStrings.forEach { (key, value) ->
analyticsParams[key] = value
}
firebaseAnalytics.setConsent(analyticsParams)