Check out what’s new from Firebase@ Google I/O 2021, and join our alpha program for early access to the new Remote Config personalization feature. Learn more

Configure Analytics Data Collection and Usage

Google Analytics offers features which allow you to control the collection and use of Analytics data.

Disable Analytics data collection

In some cases, you may wish to temporarily or permanently disable collection of Analytics data, such as to collect end-user consent or to fulfill legal obligations. Google Analytics offers multiple options for disabling and deactivating Analytics collection. Used together, they support many typical use cases.

Temporarily disable collection

If you wish to temporarily disable Analytics collection, such as to get end-user consent before collecting data, you can set the value of FIREBASE_ANALYTICS_COLLECTION_ENABLED to NO (Boolean) in your app's Info.plist file. For example, viewed in the source XML:


To re-enable collection, such as after an end-user provides consent, call the setAnalyticsCollectionEnabled instance method of Analytics. For example:




[FIRAnalytics setAnalyticsCollectionEnabled:YES];

If you need to suspend collection again for any reason, you can call




[FIRAnalytics setAnalyticsCollectionEnabled:NO];

and collection is suspended until you re-enable it. The value set by the setAnalyticsCollectionEnabled method persists across app executions and overrides the value for FIREBASE_ANALYTICS_COLLECTION_ENABLED in your app's Info.plist file. Once you set a value for setAnalyticsCollectionEnabled, Analytics collection remains in that state until setAnalyticsCollectionEnabled is called again, even if a user closes and re-opens your app.

Permanently deactivate collection

If you need to deactivate Analytics collection permanently in a version of your app, set FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES (Boolean) in your app's Info.plist file. Setting FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES (Boolean) takes priority over any values for FIREBASE_ANALYTICS_COLLECTION_ENABLED in your app's Info.plist as well as any values set with setAnalyticsCollectionEnabled.

To re-enable collection, remove FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED from your Info.plist. Setting FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to NO (Boolean) has no effect and results in the same behavior as not having FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED set in your Info.plist file.

Disable IDFA collection

If you installed Firebase through CocoaPods by adding pod 'Firebase/Analytics' to your app's Podfile and wish to disable collection of the IDFA (a device's advertising identifier) in your iOS app, ensure that the AdSupport framework is not included in your app.

To install Firebase without any IDFA collection capability, use the following subspec in place of pod 'Firebase/Analytics':

pod 'Firebase/AnalyticsWithoutAdIdSupport'

Learn more about IDFA in Apple's documentation:

Disable IDFV collection

If you wish to disable collection of the IDFV (Identifier for Vendor) in your iOS app, set the value of GOOGLE_ANALYTICS_IDFV_COLLECTION_ENABLED to NO (Boolean) in your app's Info.plist file.

Configure the use of Analytics data

Disable personalized advertising features

If you have linked your Google Analytics project to an ads account or otherwise enabled an ads integration, or opted into data sharing, your Analytics data may be eligible for use in personalized advertising. This means for instance, that you may use collected events such as first_open to create and deploy audience lists for remarketing unless you indicate that such data is not available for personalized advertising.

To programmatically control whether a user's Analytics data should be used for personalized advertising, set the appropriate default behavior in the app's AndroidManifest.xml file, and then use the methods described below to override that default behavior.

To set the default personalized advertising behavior, set the value of GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS to NO (Boolean) in your app's Info.plist file.

You can also control whether data collected from end users may be used for ads personalization via the ads personalization setting, found in Google Analytics’ Property settings.

Re-enable personalized advertising features

To re-enable personalized advertising features for a user at run-time, such as after an end-user provides consent, use the setUserProperty method as shown below:


Analytics.setUserProperty("true", forName: AnalyticsUserPropertyAllowAdPersonalizationSignals)


[FIRAnalytics setUserPropertyString:@"YES" forName:kFIRUserPropertyAllowAdPersonalizationSignals];

If you have chosen to temporarily disable analytics collection (for example, until an end-user provides consent), and you want to control personalized advertising features upon re-enabling analytics collection for a user, ensure that your call to specify this setting precedes your call to re-enable analytics collection. For example:


Analytics.setUserProperty(..., forName: AnalyticsUserPropertyAllowAdPersonalizationSignals)


[FIRAnalytics setUserPropertyString:... forName:kFIRUserPropertyAllowAdPersonalizationSignals];
[FIRAnalytics setAnalyticsCollectionEnabled:YES];

Confirming your settings

When ad personalization signals have been disabled for a user via one of the mechanisms defined above, subsequent event bundles logged from that user's device will contain a user property named "non_personalized_ads" with a value of 1 to indicate that events in that bundle are not available for personalized advertising. Disabling personalized advertising does not affect the use of the data for measurement purposes, including reporting and attribution.