17

According Firebase Android SDK Release Notes with 9.8 update we have screen tracking support with android screens and activities... The documentation says that this event works like that:

mFirebaseAnalytics.setCurrentScreen(activity,class_name,class_override_name);

In my case, I don't need overrides class name and I send null value... But i'm waiting 48h and my firebase analytics console doesn't show info about this event, any ideas?

Thanks in advance!

  • any news on this? – Vincent D. Nov 10 '16 at 22:56
  • No srry... :( The console don't show anything and documentation doesn't help... – Merlí Escarpenter Pérez Nov 11 '16 at 08:11
  • 1
    The release says: *This adds the firebase_screen parameter to every event logged while those screens are visible to app users...* I understand that the firebase generate **firebase_screen** as event but nothing... – Merlí Escarpenter Pérez Nov 11 '16 at 08:15
  • From the logs I have seen they send every screen' screen-on time. But I didn't find any place on the console which displays that. So, they are tracked for sure. – kirtan403 Nov 11 '16 at 10:48
  • 3
    I think you are confused about 2 distinct things in analytics : **event** and **parameters**. firebase_screen is really a parameter that is added automatically to all subsequent logged events, but not an event by itself. When you create an audience based on event type, you are able to further filter on event parameters. – Benoit Nov 15 '16 at 12:31
  • Then as you say, we can filter audiences with *firebase_screen* paramater, no? – Merlí Escarpenter Pérez Nov 15 '16 at 15:15
  • I have that working on my project. Can you see an event called view_item? – MiguelHincapieC Jan 22 '17 at 06:20
  • you can track it during 60seconds: https://firebase.google.com/docs/analytics/debugview https://support.google.com/firebase/answer/7201382?hl=en&utm_id=ad&authuser=0 – yozhik Jan 22 '18 at 14:44
  • And also you can see tracked events after 24 hours in Google Bigquery, which added to firebase with SQL queries. – yozhik Jan 22 '18 at 14:44

6 Answers6

9

Another very important thing that I've noticed only after two days of intensive struggling: the setCurrentScreen method MUST be called on the UI thread.

I was only able to see that after looking for a light in the Firebase decompiled code:

@MainThread
@Keep
public final void setCurrentScreen(@NonNull Activity var1, @Size(min = 1L,max = 36L) @Nullable String var2, @Size(min = 1L,max = 36L) @Nullable String var3) {
    //...
}

Whenever this method is called a event of type screen_view is logged.

And keep in mind the Firebase size restrictions. The maximum size of a screen name is 36 characters long.

  • 2
    _MUST be called on the UI thread_ - excellent note. In addition for LibGDX game developers: `Gdx.app.postRunnable ()` - it is not the same like android UI thread. You need to use android API like [here](https://stackoverflow.com/a/11129025/3926506) – Sergei Bubenshchikov Jan 16 '18 at 05:11
  • Super valuable info 5/7 would recommend – 4ndro1d Oct 30 '18 at 14:01
7

First I had the same question: where is my event with current screen name on the Firebase dashboard? I've called method mFirebaseAnalytics.setCurrentScreen(this, "MainActivity", null); with no result.

Thanks to the comment by Benoit I realized that this method indicates the value of implicit parameter that is automatically attached to any event you send. That means it's not independent event, it's a parameter that will stick to all your events since you set it.

This will be useful if you have changing screens within single Activity. For example when you have multiple fragments with one hosting Activity. And you call this method in each fragment in onResume().

If you want to have distinct metric with the name of your screen - fire explicitly a new event for that.

Bundle params = new Bundle(); 
params.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "screen");
params.putString(FirebaseAnalytics.Param.ITEM_NAME, "MainActivity");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, params);
Kirill Karmazin
  • 6,256
  • 2
  • 54
  • 42
  • 2
    Is `setCurrentScreen` still not working? I've used it and logcat shows positive result. Please see my answer here https://stackoverflow.com/a/45214101/1219012 – Artem Mostyaev Jul 20 '17 at 12:02
1
    val bundle = Bundle()
    bundle.putString(FirebaseAnalytics.Param.SCREEN_NAME, "YOUR SCREEN NAME")
    mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SCREEN_VIEW, bundle)

Also Firebase Analytic's screen tracking is automatic. No need for explicit separate event tracking.

Jayakrishnan
  • 4,457
  • 29
  • 29
0

Sets the current screen name, which specifies the current visual context in your app. This helps identify the areas in your app where users spend their time and how they interact with your app.

Note that screen reporting is enabled automatically and records the class name of the current Activity for you without requiring you to call this function. The class name can optionally be overridden by calling this function in the onResume callback of your Activity and specifying the screenClassOverride parameter.

If your app does not use a distinct Activity for each screen, you should call this function and specify a distinct screenName each time a new screen is presented to the user.

The name and classOverride remain in effect until the current Activity changes or a new call to setCurrentScreen is made. I will try to add this method to onResume Method. I do not know the result but i will share my experience.

Colibri
  • 537
  • 5
  • 8
0
firebaseAnalytics.setCurrentScreen(activity,screeenName,activity.getClass().getSimpleName());
            firebaseAnalytics.setMinimumSessionDuration(100L);
            params = new Bundle();
            params.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "screen");
            params.putString(FirebaseAnalytics.Param.ITEM_NAME, screeenName);
            firebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, params);

Try using setCurrentScreen as well as manual event fire as firebase doesn't send data immediately to the console...but if event is fired up..all the remaining data is sent to firebase..

Harsh Agrawal
  • 597
  • 3
  • 12
0

Just call that method in onResume(), and check the tracking through DebugView. it worked for me.

Check out the documentation.

Bugs
  • 4,491
  • 9
  • 32
  • 41
Manjunath
  • 1
  • 2