Disable Analytics 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. Firebase Analytics offers multiple options for disabling and deactivating Analytics collection. Used together, they support many typical use cases.

Disable Analytics collection on Android

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 false in your app's AndroidManifest.xml in the application tag. For example:

<meta-data android:name="firebase_analytics_collection_enabled" android:value="false" />

To re-enable collection, such as after an end-user provides consent, call the setAnalyticsCollectionEnabled() method of the FirebaseAnalytics class. For example:

setAnalyticsCollectionEnabled(true);

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

setAnalyticsCollectionEnabled(false);

and collection is suspended until you re-enable it.

Permanently deactivate collection

If you need to deactivate Analytics collection permanently in a version of your app, set firebase_analytics_collection_deactivated to true in your app's AndroidManifest.xml in the application tag. For example:

<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />

Disable Analytics collection on iOS

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 in your app's Info.plist file.

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

Objective-C

[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:YES]

Swift

FIRAnalyticsConfiguration.sharedInstance().setAnalyticsCollectionEnabled(true)

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

Objective-C

[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:NO]

Swift

FIRAnalyticsConfiguration.sharedInstance().setAnalyticsCollectionEnabled(false)

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 in your app's Info.plist file. Setting FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES 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 has no effect and results in the same behavior as not having FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED set in your Info.plist file.

Send feedback about...

Need help? Visit our support page.