Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual tracking does not work when using Intents. #954

Open
pkhivesara opened this issue Sep 26, 2019 · 7 comments
Open

Manual tracking does not work when using Intents. #954

pkhivesara opened this issue Sep 26, 2019 · 7 comments

Comments

@pkhivesara
Copy link

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 using FragmentTransaction.

Expected Results:

  • The setCurrentScreen should log the screen_name as expected for both scenarios.
@pkhivesara pkhivesara changed the title Manually tracking does not work when using Intents. Manual tracking does not work when using Intents. Sep 26, 2019
@pkhivesara
Copy link
Author

Anyone would be able to assist me on this? Is this a known firebase issue?

@samtstern
Copy link
Contributor

@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

@pkhivesara
Copy link
Author

@samtstern I will upload a sample repo in a bit

@pkhivesara
Copy link
Author

@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.

activity-approach

fragment-approach

Maybe I have misunderstood as to manual tracking is supposed to be used?

@samtstern
Copy link
Contributor

This looks like it might be the same issue as #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

@pkhivesara
Copy link
Author

pkhivesara commented Oct 3, 2019

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.

@dmorenus
Copy link

dmorenus commented Oct 7, 2019

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants