如何使用Firebase分析跟踪Android片段 [英] How to track android fragments using firebase analytics
问题描述
跟踪所有这些碎片作为firebase中的屏幕。
因此,理想情况下,如果可能的话,是否可以在碎片的onCreate中调用API,并告知firebase目前在fragment1,fragment2还是fragment3?
有一种特殊的方法来设置当前屏幕 -
In my android application, I have an Activity that has 3 or 4 fragments that can be attached in sequence based on some user or server events.
I would like to track all these fragments as screens in firebase.
So ideally, if possible, is there an API i can invoke in the onCreate of the fragments, and tell firebase that user is currently in fragment1, fragment2 or fragment3?
There is a special method to set a current screen - setCurrentScreen
I used it as follows
mFirebaseAnalytics.setCurrentScreen(this, fragment.getClass().getSimpleName(), fragment.getClass().getSimpleName());
Once the method is called, the following message appears in the LogCat
Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=HomeFragment, firebase_previous_id(_pi)=4121566113087629222, firebase_previous_screen(_pn)=HomeFragment, firebase_screen_class(_sc)=StatisticsFragment, firebase_screen_id(_si)=4121566113087629223, firebase_screen(_sn)=StatisticsFragment}]
The following event appears on auto activity tracking:
Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=StatisticsFragment, firebase_previous_id(_pi)=4121566113087629223, firebase_previous_screen(_pn)=StatisticsFragment, firebase_screen_class(_sc)=LoginActivity, firebase_screen_id(_si)=4121566113087629224}]
As you see, they are almost the same, so setCurrentScreen
is working.
I'm able to see those classes in Firebase Console only on the next day. It is normal for Firebase - it takes time to process such amounts of data.
这篇关于如何使用Firebase分析跟踪Android片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!