quickstart-android
quickstart-android copied to clipboard
Manual tracking does not work when using Intents.
Step 1: Describe your environment
- Android device: Pixel 3
- Android OS version: Android 9
- Google Play Services version:
- Firebase/Play Services SDK version: 17.2.0
Step 2: Describe the problem:
While using the setCurrentScreen
method to manually track user engagements, the screen_name
is omitted when using Intent
to move from one activity
to another.
However, if a FragmentTransaction
is executed, the screen_name
tag is logged successfully.
Observed Results:
- The
screen_name
tag is not logged when using an Intent. However it works as expected when usingFragmentTransaction
.
Expected Results:
- The
setCurrentScreen
should log the screen_name as expected for both scenarios.
Anyone would be able to assist me on this? Is this a known firebase issue?
@pkhivesara thanks for filing this, sorry about my very slow response. Could you show the piece of code that's not working as expected?
Also could you try using this method to gather logs of what's being sent? https://firebase.google.com/docs/analytics/events?platform=android#view_events_in_the_android_studio_debug_log
@samtstern I will upload a sample repo in a bit
@samtstern Please find the sample code: https://gitlab.com/pkhivesara/firebasetest
Attached along are two screenshots, using fragment and activity approach both of which fail to register the firebase_screen/ga_screen
attribute.


Maybe I have misunderstood as to manual tracking is supposed to be used?
This looks like it might be the same issue as https://github.com/firebase/quickstart-android/issues/935
So are you saying this is the line that doesn't work? https://gitlab.com/pkhivesara/firebasetest/blob/master/app/src/main/java/com/test/firebaseandroidsample/SecondActivity.java#L18
The screen_class
is being registered however firebase_screen/ga_screen
always shows as NOT SET (as we can see in the screenshot). Any ideas on how to set the firebase_screen
attribute. This is a major bug as far as tracking is concerned.
The app appears to be calling setCurrentScreen()
from onCreate()
in its activity, fragment, etc. This is not where you'd want to call setCurrentScreen()
as onCreate()
is for logic that gets called once during the app's lifetime. Instead it should be called from onResume()
.
We do automatic screen tracking based on activity lifecycles but not fragment lifecycles. So, regardless of whether setCurrentScreen()
were called on an activity resume we would log a screen_view event. However, automatic screen tracking does not set a screen name.
So in the absence of any manual calls to setCurrentScreen()
I'd expect to see the events you're seeing when the activity is shown. I'm not sure why you're getting the desired results with FragmentTransaction
.
In any case you'll probably get much better results just moving your calls to setCurrentScreen()
from onCreate()
to onResume()
.