Exclude testing device from Firebase Analytics logging

firebase analytics testing
disable firebase analytics android
firebase analytics plugin
get firebase analytics data
flutter firebase analytics debug
firebase to google analytics
firebase analytics angular

I am sure that Firebase is counting all my development work too in its analytics. I open my app like hundred times a day to debug and test on a few devices, it's really skewing up my readings.

I have used a function to get me a somewhat unique ID to represent my devices and ignored all its analytics through code.

public static String getPsuedoID() {
    String m_szDevIDShort = "35" + (Build.BOARD.length() % 10)
    + (Build.BRAND.length() % 10) + (Build.VERSION.SDK_INT % 10)
    + (Build.DEVICE.length() % 10) + (Build.DISPLAY.length() % 10)
    + (Build.MODEL.length() % 10) + (Build.PRODUCT.length() % 10);

    String serial;
    try {
        serial = android.os.Build.class.getField("SERIAL").get(null).toString();
        return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
    } catch (Exception exception) {
        serial = "getUniquePsuedoIDfailed";
    return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();

But I just figured out it is not as unique as I assumed. Apparently, my ID was same as around a few (very few) users.

Is there a foolproof method to do just this?

You can control analytics collection using manifest metadata with the setting defined by a manifestPlaceholder:

    //... >
        android:value="${analytics_deactivated}" />

Then define the placeholder value in the build variant blocks of your build.gradle file:

buildTypes {
    debug {
        manifestPlaceholders = [analytics_deactivated: "true"]

    release {
        manifestPlaceholders = [analytics_deactivated: "false"]

Configure Analytics Data Collection and Usage, Get Started · Refine Public Content Indexing · Log User Actions · Test To enable Analytics Debug mode on an Android device, execute the following commands: in debug mode will be excluded from your overall Analytics data, and will corresponds to the time of its logging on the development device. Make sure that you've set up your project and can access Analytics as described in Get Started with Analytics. Log events. After you have configured the firebase.analytics() instance, you can begin to log events with the logEvent() method. If you're already familiar with Google Analytics, this method is equivalent to using the event command in

A solution using the ANDROID_ID

Android has a provision of a unique device ID called the ANDROID_ID, a 64-bit number that is randomly generated when the user first sets up the device and remains constant thereafter. By leveraging this ANDROID_ID we can uniquely identify the testing devices.

Note: Unlike Firebase's provision of controlling analytics collection, this method will also work on Release builds/APKs.

1) Get ANDROID_ID of all your testing devices:

private static String getDeviceID(Context c) {
    return Settings.Secure.getString(c.getContentResolver(), Settings.Secure.ANDROID_ID);

2) Once done, add the IDs to an array:

private static String testingDeviceIDs[] = {"8ab5946d3d65e893", "ada1247bfb6cfa5d", ...};

3) Check if the device is one of the testing devices.

private static boolean isDeviceForTesting(Context c) {
    for (String testingID : testingDeviceIDs)
        if (getDeviceID(c).equals(testingID))
            return true;
    return false;

4) Finally, log Firebase events only if the device is not a testing device.

static void logFirebaseEvent(Context c, String name) {
    if (!isDeviceForTesting(c))
        FirebaseAnalytics.getInstance(c).logEvent(name, null);

Debugging Events, Currently, DebugView keeps a log of events for 30 minutes for each configured device. Test device setup. To enable sending of DebugView data  Note: The part of the log name following /logs/ must be URL-encoded. This means that the forward-slash character, /, must be written as %2F. Service name. Firebase Management audit logs use the service name firebase.googleapis.com. For more details on logging services, go to Mapping services to resources. Resource types

Should be able to do something like following:

    if (BuildConfig.DEBUG) {

Debugging Events in Firebase Analytics, To enable Analytics Debug mode on an emulated Android device, execute the following adb shell setprop debug.firebase.analytics.app <package_name> Each event displays a timestamp that corresponds to the time of its logging on the​  6 Exclude testing device from Firebase Analytics logging Oct 20 '17 4 Change what's new section in PlayStore without relseasing an update Apr 29 '17 3 Join images using Alibaba's OSS image processing Mar 11 '18

The firebase docs only describe that it can be disabled from within the apk.


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



source: https://firebase.google.com/support/guides/disable-analytics

Validate your Analytics configuration with DebugView, Use this option to identify events as conversions before you start logging them. *All attribution models in Firebase exclude direct visits from receiving with an app install, Google Analytics for Firebase examines whether an app-install ad was then it also knows not to serve that device any additional ads for that app. You can view aggregrated statistics about your Analytics Events in the Firebase console dashboards. These dashboards update periodically throughout the day. For immediate testing, use the logcat output as described in the previous section. To access this data in the Firebase console: In the Firebase console, open your project.

If what you were looking was to disable the Firebase Analytics / tracking for the test devices that run the Firebase tests or the Play Console Pre-launch reports (which are actually Firebase tests), then you need to disable them based on a system string:

String testLabSetting = Settings.System.getString(context.getContentResolver(), "firebase.test.lab");
if ("true".equals(testLabSetting)) {

So basically, it's a combination of checking if your device is is a Firebase Test device, and then you disable the FirebaseAnalytics for it.

Conversions - Firebase Help, Many (including myself) still sometimes call it Firebase Analytics, does not have access to the Advertising Identifier on a user's device, Interactions within the app that are being tracked via event logging for Firebase. User properties can also be used with Firebase Remote Config for A/B testing as well  Getting started with Analytics is easy. Just add the Firebase SDK to your new or existing app, and data collection begins automatically. You can view analytics data in the Firebase console within hours. Log custom data: You can use Analytics to log custom events that make sense for your app, like E-Commerce purchases or achievements. Create

Google Analytics For Firebase: A Reporting Introduction, Use Google Tag Manager to get Firebase Analytics up and running for your essentially be logging events into Firebase with optional parameters containing In fact, you could completely ignore the Firebase Analytics reports altogether Testing Firebase and Google Analytics on a mobile app can be  This approach conserves the battery on end users’ devices and reduces network data usage. However, for the purposes of validating your analytics implementation (and, in order to view your analytics in the DebugView report), you can enable Debug mode on your development device to upload events with a minimal delay.

Getting Started With Firebase Analytics For Apps, In mobile app development, Firebase Crashlytics is one of the most If you want to exclude debug builds from polluting your crash logs reported to us by our users especially during the beta test phase. There are no ways in which logs can be filtered out based on a specific OEM, device category or  Automatically collected events are triggered by basic interactions with your app. As long as you use the Firebase SDK, you don't need to write any additional code to collect these events. To see event reports , click Events in the report navigation in Google Analytics, or click the Events tab in the Firebase console.

Effective logging in Production with Firebase Crashlytics, I learnt about Firebase remote config and experiments about a year and a By linking BigQuery to Firebase, all analytics data related to A/B tests can be accessed. The application is be configured to ignore this value if empty and This is also true if the same user logs into the app on a different device. Automatically collected user properties As long as you use the Firebase SDK, you don't need to write any additional code to collect a number of user properties automatically. All of these user properties are available for use in Audience conditions, and some of them are also available as general report filters.

  • That's it, Thanks.
  • but what if i don't want to log events from specific devices even when it is signed APK downloaded from Play Store? Our team often performs tests on live application.
  • @shashwat you can look to my solution a little below. I believe it will work out for your use case.
  • but what if i don't want to log events from specific devices even when it is signed APK downloaded from Play Store? Our team often performs tests on live application.