90

Background

In the recent months, Google has published a new Analytics alternative, called "Firebase Analytics" .

The problem

As the app already does have Google-Analytics, I find some obstacles that I can't see how to best handle.

The questions

  1. Previously, "newTracker" function needed a property-id. Now I don't see it. Does it mean it doesn't need one?

  2. Previously, "enableAdvertisingIdCollection " was available to collect ads info too. I can't find it in new APIs. Is it automatically collected?

  3. "setDryRun" was available to disable sending the data to the servers, and now I don't see it. Does it mean it's automatically this way for debug versions of the app? Do all functions write to the logs?

  4. Previously, I could track a "screen" :

    public void setScreenName(String name) {
        mGoogleAnalyticsTracker.setScreenName(name);
        mGoogleAnalyticsTracker.send(new HitBuilders.ScreenViewBuilder().build());
    }
    

    Now I don't see it, but as I've read, I think it's automatic, so it sends data of the activity lifecycle anyway. Is it true?

  5. Probably the most important thing: previously I could track using category, action, label and value:

    public void trackEvent(final String category, final String action, final String label, final long value) {
        mGoogleAnalyticsTracker.send(new HitBuilders.EventBuilder()
                .setCategory(category).setAction(action)
                .setLabel(label).setValue(value).build());
    }
    

    and now I see a completely different way to track events ("custom events"), using bundles. Example:

    Bundle bundle = new Bundle();
    bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id);
    bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name);
    bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image");
    mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
    

    How does it work? How is it shown in the website of Firebase Analytics? I suppose I could have the first parameter of logEvent behave like the category parameter of the Google-Analytics, but what can/should I do for the rest? According to the docs, this should be ok:

    public void trackEvent(final String category, final String action, final String label, final long value) {
        Bundle bundle = new Bundle();
        bundle.putString("action", action);
        bundle.putString("label", label);
        bundle.putLong("value", value);
        mFirebaseAnalytics.logEvent(category, bundle);
    }
    
  6. Which events are actually automatically being tracked (I ask this because some are said that I shouldn't use, here) ? Do they include purchases? app-invites? ads? Where do I see them in the console website ?

  7. About logs, it says that the new SDK does it by :

    You can enable verbose logging with a series of adb commands:

    adb shell setprop log.tag.FA VERBOSE adb shell setprop log.tag.FA-SVC VERBOSE adb logcat -v time -s FA FA-SVC

    What do those commands do? How can I disable it? I've noticed it even gets shown in release version of the app...

  8. Is the new SDK supposed to replace Google-Analytics? Is it suggested to fully move to it? Will Google-Analytics have any updates?

Pang
  • 9,564
  • 146
  • 81
  • 122
android developer
  • 114,585
  • 152
  • 739
  • 1,270

2 Answers2

61

Lots of questions bundled together so I'll try to briefly answer most of them:

  1. Google Analytics reports on tracker-ids, Firebase Analytics reports on applications. There is only one id in the application defined in your google-services.json. The ID is translated to a string resource by google services plugin under "google_app_id" name. All events from the app are reported to this single id.
  2. Firebase Analytics reports AdId automatically. You don't need to enable it.
  3. There is no dryRun feature. You can either use separate google-services.json during development, filter out development version using the app version or add user-property to mark the app instances used for development.
  4. You can report screens with

    Bundle params = new Bundle();
    params.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "screen");
    params.putString(FirebaseAnalytics.Param.ITEM_NAME, "screen name");
    firebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, params);
    
  5. You can log custom event with the same params

    Bundle params = new Bundle();
    params.putString("category", category);
    params.putString("action", action);
    params.putString("label", label);
    params.putLong("value", value);
    firebaseAnalytics.logEvent("xyz_event", params);
    

    The "ga_" prefix is reserved and your analytics will fail if you use it. Instead, use "xyz_" where xyz is your company's initials, for example.

    Do not use the category as event name unless you have very few categories you want to track. Firebase Analytics supports up to 500 event names. Logging more than that will cause some of your data to be ignored.

  6. There is a list of reserved event names in the beginning of the FirebaseAnalytics.Event class. It roughly represents the automatic events reported.

  7. Firebase Analytics has debug logging disabled by default. It only logs errors and warnings. If you don't enable debug logging and your app is correctly configured there are only 2 lines that are being logged when the app starts with instructions on how to enable debug logging. There is nothing to disable in production and there is no equivalent to setLogLevel(ERROR) from Google Analytics. WARN is the default logging level. You can only enable logging on individual device by running the adb command on the device). That helps you avoid shipping app in production with debug logging enabled.

  8. Google Analytics SDK for Android and iOS is not deprecated and will be supported and updated for foreseeable future. You don't need to move away from it if you already invested using it in your app and it is meeting your needs.

pdub
  • 165
  • 1
  • 8
djabi
  • 5,601
  • 18
  • 25
  • 1. ok, so it's in the json file. 2. Nice. 3. What's the default behavior? 4. But is it needed, or already automatic? 5. We have a lot less than even 100 categories, but I've now tested this code, and the result on the website doesn't show any information about the other stuff I've put into the bundle. How can I show this data? Only the category is shown. 6. For some reason "app_uninstall" is 0, while "app_remove" is not. What's the difference? 7.This seems incorrect, because I do see its logs, even in release version of the app. How come? 8. Will Firebase have all its features? – android developer Jun 21 '16 at 07:07
  • 5. BTW, the value is "long" type. – android developer Jun 21 '16 at 07:11
  • 3
    5. It seems it's not supported yet to use custom bundle stuff, according to these posts: http://stackoverflow.com/a/37779048 , http://stackoverflow.com/a/37511858 . Too bad. – android developer Jun 21 '16 at 07:25
  • 1
    Thanks for the comment. Changed value to long in 5. There is no automatic reporting on all params yet but you can link the account to BigQuery and use that to create reports. BigQuery has some free quota that might be all you need. Abotu 3. The default is reporting. 4. Screen reporting is not automatic. You need to log the event when you display content. 5. If the default reporting is not sufficient you can query the data in BigQuery. It has the raw events as you logged them. 6. You should ignore app_uninstall. 7. If you enable debug logging *on a device* you will see all logs. – djabi Jun 22 '16 at 16:52
  • 1
    8. This is very broad question. What particular features you are asking about. If Firebase Analytics is identical to Google Analytics it will be Google Analytics not Firebase Analytics. – djabi Jun 22 '16 at 16:55
  • 3. what's the easiest way to avoid reporting? Maybe via code (BuildConfig.DEBUG, for example) ? 4. Ok. 5. Too bad. 6. What does it mean? 7. Is it temporary? Can I disable it? Can I make it show logs only for debug versions of the app? 8. Well I want to know if I will be able to replace Google-Analytics with Firebase-Analytics. I don't know about all features of each, but I'd like to have at least the ability to handle custom-events properly – android developer Jun 23 '16 at 06:53
  • 6. Its an older version of app_remove event that was replaces. 7. It is temporary only for the device you set the log tag property. Rebooting the device reverts back to the default behavior (only logging errors&warnings). You can disable it by setting the property to ERROR or WARN. How logging works in Android is explained in https://developer.android.com/reference/android/util/Log.html#isLoggable(java.lang.String, int) – djabi Jun 23 '16 at 21:18
  • 6. ok. 7. odd. Why isn't it available via code itself (enable/disable logs of the API, which is mostly useful for when you are in a debug build)? BTW, your link doesn't fully work as you've intended. – android developer Jun 25 '16 at 09:02
  • 1
    I believe you can use `firebaseAnalytics.setAnalyticsCollectionEnabled(false)` as an alternative to `dryRun`. See more here: https://firebase.google.com/support/guides/disable-analytics – dsrees Oct 06 '16 at 13:17
  • 3. I use `[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:NO];` to disable log collection – Danik Nov 11 '16 at 15:37
  • Sorry, but I don't get 4. I've added this, I can see sending this event in logs, but I cannot see that event in firebase console. I can see only 'app-remove', 'first_open' and 'session_start'. – Makalele Dec 15 '16 at 14:32
  • #4. there is a method called setCurrentScreen() but don't confuse it with the event that indicates the current screen. This method changes an implicit parameter that automatically adds to your event with the screen name. It will be useful in model where you have 1 Activity and lots of screens, fragments for example. You can read about this method here: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics Again: don't expect to see the name of Activities in Firebase event dashboard after executing this method. You'll need explicit event for that. – Kirill Karmazin Feb 24 '17 at 19:41
  • 2
    'The "firebase_", "google_", and "ga_" prefixes are reserved and should not be used.': https://firebase.google.com/docs/reference/cpp/group/parameter-names My suggestion instead of "ga_event" would be "abc_event" where "abc" is an acronym for you or your company. – KRA2008 May 01 '19 at 20:47
  • 6
    I landed here as it is now 2019 and Google are soon deprecating GA in favour of FA, so the move is mandatory. https://support.google.com/firebase/answer/9167112 – Ryan Jun 10 '19 at 13:11
14

Google Analytics is a freemium web analytics service offered by Google that tracks and reports website traffic.1 Google launched the service in November 2005 after acquiring Urchin. Firebase is a cloud services provider and backend as a service company based in San Francisco, California. The company makes a number of products for software developers building mobile or web applications.

How to move from google analytics to firebase analytics?

Google Analytics (GA) and Firebase Analytics (FA), despite their common name, are widely different in many aspects. While GA is a general-purpose (and more web oriented) analytics tool, Firebase was built keeping mobile in mind: therefore, the feature set is different between the two, with some things that were added in FA and things that are missing from GA.

More specifically, these are some noteworthy points when considering Firebase Analytics:

  • Real-time view is missing
  • Events are available after a 4-6 hours period
  • Behavior Flow (from GA) is missing
  • The Audiences feature a big advantage of FA and, coupled with Notifications, allows you to engage with a specific group of users
  • When using Firebase Crash Reporting, an audience with users who experienced a crash is automatically created
  • Funnel analysis makes much more sense than in GA, since FA is based on events and not on screen views
  • Free and unlimited, except for the number of types of events (limited to 500); no limits on the volume of events per each type
  • Some events are logged automatically (i.e., sessions based on Activity lifecycle)
  • Relatively low methods footprint, compared to GA's methods count
  • Dead-easy to setup, there is no singleton to initialize, just include the Gradle dependency and start logging events
  • All-in-one console, if you plan on using other Firebase services

As to if one should consider switching from one to the other, or if to keep both in parallel, the answer is: it depends.

  • If you were using GA extensively before, chances are that you would be missing some of its feature when switching completely to FA.
  • However, if this is a fresh start for your project, FA is much more prone to a cross-platform mobile-oriented environment, so you may very well consider it as your own analytics tool.

On a side note, keep in mind that Firebase has just launched and Google has plans on adding more features in the coming weeks (e.g., real-time dashboard).

For tutorial you can find here https://firebase.google.com/docs/analytics/android/start/

Blackbam
  • 17,496
  • 26
  • 97
  • 150
Shubham Sharma
  • 2,763
  • 5
  • 31
  • 46
  • 12
    I landed here as it is now 2019 and Google are soon deprecating GA in favour of FA, so the move is mandatory. https://support.google.com/firebase/answer/9167112 – Ryan Jun 10 '19 at 13:11
  • 1
    So this means we have to use Firebase Analytics instead of Google Analytics? Am i correct? – Sumit Shukla Feb 14 '20 at 05:49
  • @Ryan holy cow! I wanted to go to Google Analytics **from** Firebase Analytics, but Your comment saved me! Thanks! – Aleksandar Feb 28 '20 at 10:29