Google Analytics introduces Consent Mode v2, providing a streamlined approach to adjust your SDK's behavior based on user consent status. This feature lets you easily indicate whether consent has been granted for Analytics and Ads cookies. To implement Consent Mode v2 for your apps, follow these straightforward steps:

  • Utilize Google Analytics for Firebase SDK to set default consent values.
  • Employ the setConsent method programmatically to update these values based on in-app user consent.

For more information, see Consent mode on websites and mobile apps.

Consent Types and Impact

Consent Types Consent Mode V2 InMobi CMP (Web) Description
ad_storage Mandatory Supported Enables storage for advertising, like web cookies or app device identifiers.
analytics_storage Mandatory Supported Enables storage for analytics, e.g., visit duration cookies or app device identifiers.
ad_user_data Mandatory Supported Consent is required to send user data to Google for online advertising.
ad_personalization Mandatory Supported Consents to personalized advertising.


  • By default, the Google basic consent feature is disabled within the portal. Enable it manually to activate.

Configure Google Consent Mode in InMobi CMP

  1. Log in to the InMobi CMP portal.
  2. Navigate to your Property settings:
    • For new apps: Under the Properties tab, click PROTECT AN APP for your sites, and enter all the necessary information. For more information, see Protect An App.
    • For existing apps: Under the Properties tab and from the list of properties, click the edit icon for the desired site and enter all the information required on the Edit an App page.
  3. In the ENABLE GOOGLE BASIC CONSENT field, select Yes, and a popup window appears.

  4. Select the target location in the WHICH USERS SHOULD BE ASKED FOR CONSENT field.
  5. Select the purpose(s) and default value(s).


    After selecting GBC on the portal for AMP sites and saving it, you should copy the final AMP tag and update it on your AMP site. Unlike the non-AMP sites, you should manually update the AMP sites' tags after any configuration changes.

GBC Implementation

Configure Default Consent Value

To enable GBC for your Android app, you need to first set the default consent state and values.

  1. Set the default consent state in AndroidManifest.xml file. Update the consent state based on the user interaction with the consent settings.
  2. To set the default consent state, open your app's AndroidManifest.xml file since no consent mode values are pre-configured by default.
  3. Add the consent mode key-value pairs. The key describes the consent type, and the value indicates the consent state. You can set the value for the following as true (consent granted) or false (consent denied):
    • google_analytics_default_allow_analytics_storage
    • google_analytics_default_allow_ad_storage
    • google_analytics_default_allow_ad_user_data
    • google_analytics_default_allow_ad_personalization_signals
  4. Save your changes and update the consent values similarly as shown in the example below:
    <meta-data android:name="google_analytics_default_allow_analytics_storage" android:value="true" />
    <meta-data android:name="google_analytics_default_allow_ad_storage" android:value="true" />
    <meta-data android:name="google_analytics_default_allow_ad_user_data" android:value="true" />
    <meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="true" />

Implement Update Parameter

  1. Google basic consent can be part of the GDPR or CCPA popup and it can be shown separately. Use the showGBCScreen(activity: Activity) API to show the standalone popup:


    fun showGoogleConsent() {
      // Show Google basic consent


    public void showGoogleConsent() {
        // Show Google basic consent
  2. Implement the callback onGoogleBasicConsentChange(consents: GoogleBasicConsents):


    override fun onGoogleBasicConsentChange(consents: GoogleBasicConsents) {
        Log.i("Ad Storage", consents.adStorage.value)
        Log.i("AdUserData", consents.adUserData.value)
        Log.i("AdPersonalization", consents.adPersonalization.value)
        Log.i("AnalyticsStorage", consents.analyticsStorage.value)


    public void onGoogleBasicConsentChange(GoogleBasicConsents consents) {
        Log.i("Ad Storage", consents.getAdStorage().getValue());
        Log.i("AdUserData", consents.getAdUserData().getValue());
        Log.i("AdPersonalization", consents.getAdPersonalization().getValue());
        Log.i("AnalyticsStorage", consents.getAnalyticsStorage().getValue());
  3. Update consent using the above callback. To update the Consent Type values, retrieve the consent values from the onGoogleBasicConsentChange(consents: GoogleBasicConsents) callback and set the consent using the setConsent method of Google’s Analytics API. The callback will be called only when Google consent is enabled in the portal and consent is given by the user. It won’t be called during the consecutive app launches.


    You need to call the setConsent method to set the consent provided by the callback API. InMobi CMP will NOT automatically set the setConsent method.

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


    override fun onGoogleBasicConsentChange(consents: GoogleBasicConsents) { {
            adStorage = consents.adStorage == GBCConsentValue.GRANTED
            adUserData = consents.adStorage == GBCConsentValue.GRANTED
            adPersonalization = consents.adStorage == GBCConsentValue.GRANTED
            analyticsStorage = consents.adStorage == GBCConsentValue.GRANTED


    public void onGoogleBasicConsentChange(GoogleBasicConsents consents) {
    // Set consent types.
    Map<ConsentType, ConsentStatus> consentMap = new EnumMap<>(ConsentType.class);
    consentMap.put(ConsentType.ANALYTICS_STORAGE, consents.getAnalyticsStorage() == GBCConsentValue.GRANTED ?
            ConsentStatus.GRANTED : ConsentStatus.DENIED);
    consentMap.put(ConsentType.AD_STORAGE, consents.getAdStorage() == GBCConsentValue.GRANTED ?
            ConsentStatus.GRANTED : ConsentStatus.DENIED);
    consentMap.put(ConsentType.AD_USER_DATA, consents.getAdUserData() == GBCConsentValue.GRANTED ?
            ConsentStatus.GRANTED : ConsentStatus.DENIED);
    consentMap.put(ConsentType.AD_PERSONALIZATION, consents.getAdPersonalization() == GBCConsentValue.GRANTED ?
            ConsentStatus.GRANTED : ConsentStatus.DENIED);

    The value set by the setConsent method persists across app executions and overrides the default values configured through the AndroidManifest.xml file. The value remains in that state until setConsent is called again, even if a user closes and reopens the app.

On This Page

Last Updated on: 31 Mar, 2024