Manage consent settings (apps)

This page is for developers that maintain Google Analytics for an app and want to integrate consent mode. For an introduction to consent mode, read Consent mode for websites and apps.

Google Analytics offers Consent Mode to adjust how your Google tags behave based on the consent status of your users. You can indicate whether consent has been granted for Analytics and Ads identifiers. To implement Consent Mode for apps, use the Google Analytics for Firebase SDK to set a default setting and use the setConsent API to manage the setting programmatically, based on in-app user consent. To learn more, see Consent Mode.

Initial setup

By default, Analytics and Ad storage are enabled. Follow the instructions below to change the default state for your app.

Analytics storage

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

<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 NO in your app's Info.plist file. For example, viewed in the source XML:

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

To re-enable Analytics and Ad storage, such as after an end-user provides consent, call the setConsent instance method of Analytics.

To update the Analytics and Ad storage values after an app has launched, call the setConsent method.

The value set by the setConsent method persists across app executions and overrides the default setting. 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.

The following example shows the setConsent method updating values for Analytics and Ad storage to granted:

Swift

Analytics.setConsent([
  .analyticsStorage: .granted
  .adStorage: .granted
])

Objective-C

[FIRAnalytics setConsent:@{
  FIRConsentTypeAnalyticsStorage : FIRConsentStatusGranted
  FIRConsentTypeAdStorage : FIRConsentStatusGranted
}];

You can verify that your consent settings are working as intended by viewing the Xcode debug console for your app.

Follow these steps:

  1. Enable verbose logging on your device.
  2. In the Xcode debug console, look for ad_storage or analytics_storage. For example, if both Analytics and Ad storage are enabled, then you'll see the following message:

    ad_storage is granted. analytics_storage is granted.