Skip to main content

Google Consent Mode

The Osano Consent Manager React Native SDK supports Google's Consent Mode v2, providing seamless integration with Firebase Analytics and other Google services. This feature automatically maps Osano consent categories to Google Consent Mode parameters, ensuring compliance with Google's data collection requirements.

Prerequisites

  1. Enable Google Consent Mode in your Osano configuration on the Osano website
  2. React Native Firebase Analytics must be integrated in your project (Firebase Setup Guide)
  3. Configure consent defaults for GDPR compliance

Quick Setup

Android (AndroidManifest.xml)

Add these <meta-data> tags to your Android AndroidManifest.xml within the <application> tag:

<application>
<meta-data android:name="google_analytics_default_allow_analytics_storage" android:value="false" />
<meta-data android:name="google_analytics_default_allow_ad_storage" android:value="false" />
<meta-data android:name="google_analytics_default_allow_ad_user_data" android:value="false" />
<meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="false" />

<!-- For EEA countries, you can use "eu_consent_policy" instead of "false" -->
<!-- <meta-data android:name="google_analytics_default_allow_ad_user_data" android:value="eu_consent_policy" /> -->
<!-- <meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="eu_consent_policy" /> -->
</application>

iOS (Info.plist)

Add these keys to your iOS Info.plist file to set Google Consent Mode v2 default values:

<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE</key>
<false/>
<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE</key>
<false/>
<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA</key>
<false/>
<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS</key>
<false/>

<!-- For EEA countries, you can use the string "eu_consent_policy" instead of false -->
<!--
<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA</key>
<string>eu_consent_policy</string>
<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS</key>
<string>eu_consent_policy</string>
-->

📝 Note: The example below demonstrates integration with React Native Firebase Analytics setConsent, but you can use the consentMap data in any way that works for your setup (custom analytics, other Firebase libraries, etc.).

Implement the callback to receive consent updates and apply them to React Native Firebase:

import analytics from '@react-native-firebase/analytics';

const googleConsentModeCallback = (consentMap: { [key: string]: string }) => {
analytics().setConsent(consentMap);
};

3. Configure the ConsentManager

Set the callback when initializing your ConsentManager:

import { ConsentManager } from '@osano/osano-cmp-react-native';

const consentManager = ConsentManager.configure({
configId: 'your_config_id',
customerId: 'your_customer_id',
consentingDomain: 'your_domain',
googleConsentModeCallback: googleConsentModeCallback,
});

How It Works

Category Mapping

The SDK automatically maps Osano consent categories to Google Consent Mode v2 parameters:

Osano CategoryGoogle Consent Mode Parameters
ANALYTICSanalytics_storage
MARKETINGad_storage, ad_user_data, ad_personalization
Other categoriesNo mapping (Essential, Personalization, Storage, etc.)
  1. App Launch: Manifest/Info.plist defaults are applied
  2. SDK Initialization: If user has existing consent, callback is triggered immediately
  3. Remote Consent Sync: If remoteConsent is enabled and user data (extUsrData) is provided, the SDK fetches remote consent from Osano servers and compares timestamps with local consent to use the most recent version
  4. User Interaction: When user grants/denies consent, callback is triggered with updated parameters
  5. Firebase Update: Your callback converts and applies consent to Firebase Analytics

Automatic TCF Integration

As your Consent Management Platform (CMP), Osano automatically enables TCF (Transparency & Consent Framework) integration when both Google Consent Mode and IAB/TCF are enabled in your Osano configuration. No additional configuration is required.

The SDK handles this automatically by:

  • Setting the IABTCF_EnableAdvertiserConsentMode parameter to 1 when both Google Consent Mode and IAB TCF are applicable for the user
  • Providing all required IABTCF SharedPreferences (Android) and NSUserDefaults (iOS) keys that Google services expect
  • Enabling this only when both features are active and TCF is applicable for the user's region
  • Allowing Google services to read the TCF consent string directly for detailed consent information
  • Automatically disabling TCF integration (IABTCF_EnableAdvertiserConsentMode = 0) when either feature is not applicable

Note: The google_analytics_tcf_data_enabled flag is not required when using Osano as your CMP, as we handle TCF enablement automatically.

Additional Resources