Screen tracking support - Firebase 9.8
Solution 1
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.
Solution 2
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);
Solution 3
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.
![Merlí Escarpenter Pérez](https://i.stack.imgur.com/peRSC.jpg?s=256&g=1)
Merlí Escarpenter Pérez
My studies and titles: Professional Formation : DMA (Developing Multiplatform Apps) My develop experiencies: C# Developer Windows Phone 8.x Developer Android Developer
Updated on June 08, 2022Comments
-
Merlí Escarpenter Pérez about 2 years
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!
-
Alex over 7 years"Note that screen reporting is enabled automatically" - ok where in console I can find this reporting ?
-
JacksOnF1re about 7 yearsIn the dashboard i.e.
-
Artem Mostyaev almost 7 yearsIs
setCurrentScreen
still not working? I've used it and logcat shows positive result. Please see my answer here stackoverflow.com/a/45214101/1219012 -
Alp Altunel over 6 yearsit can be found underEvents->Screen View
-
Sergei Bubenshchikov over 6 yearsMUST 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 -
4ndro1d over 5 yearsSuper valuable info 5/7 would recommend