How does Firebase Analytics define a session?

13,030

Solution 1

And I'll answer my question by saying that Firebase Analytics defines a session as a user engaging with your app for a minimum amount of time (10 seconds by default) followed by your user not engaging with your app for a certain amount of time (30 minutes by default). But you can change those times if you'd like something different.

So if a user starts using your app, switches to messaging to send a message, goes back to your app, switches to messaging again to send a quick selfie, then goes back to your app, that's all considered just one session.

Similarly if a user accidentally taps on your app icon and then quickly switches away to open up the app they actually meant to open, that won't get recorded as a session.

Solution 2

Adding to Todd Kerpelman's response above, you can customize the definition of a session via FirebaseAnalytics.setSessionTimeoutDuration(long millis).

The docs are at: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics

(Sorry, don't have the reputation to make this a comment)

[EDIT: removed obsolete reference to setMinimumSessionDuration]

Share:
13,030
Todd Kerpelman
Author by

Todd Kerpelman

Hello world!

Updated on June 28, 2022

Comments

  • Todd Kerpelman
    Todd Kerpelman about 2 years

    Firebase Analytics has a number of stats around "Sessions" (like "Sessions per user" and "Average session length"), but how exactly does Firebase Analytics define a session?

  • AL.
    AL. over 7 years
    Thanks for that easy-to-absorb info Todd. I'm not quite familiar with Firebase Analytics, but I noticed you mentioned that "But those exact times are subject to change." -- is it possible for the developer to define the duration (i.e. the user not engaging part, instead of 30 mins, set it to 1 hour or so) on when to consider that it is a "Session"?
  • Todd Kerpelman
    Todd Kerpelman over 7 years
    Thanks, Dan! I've update my answer to reflect your comments.
  • Todd Kerpelman
    Todd Kerpelman over 7 years
    Hi, AL. As Dan noted below, these are default values and you can change them. On Android, it's within the Firebase Analytics class and on iOS, it's through the FIRAnalyticsCofiguration class
  • Michael Sotnikov
    Michael Sotnikov over 7 years
    @ToddKerpelman, What "as a user engaging with your app" is stand for? Is it UI events sent or any firebase events? I'm interested in the context of Android TV's "tv input" applications, which usually doesn't have it's own UI
  • Todd Kerpelman
    Todd Kerpelman over 7 years
    @MichaelSotnikov It simply means a user has your app in the foreground on their device.
  • Michael Sotnikov
    Michael Sotnikov over 7 years
    @ToddKerpelman, Thank You. But I specifically mentioned AndroidTV. Cause there is no own UI for "tv input app". It works as the service for host system app (Live Channels) which has own UI. So there is no background/foreground for client app. But if it sends other events to Firebase analytics will it be counted as session activity? Any other way to say firebase that session is active, cause for "tv input" app it's real session - user watches channel, switches channels and peroform other UI activities but not through client app, but through host app (Live Ch. or other vendor's derivatives)
  • StuartDTO
    StuartDTO over 6 years
    Can you help me with this question please?
  • Hamid Zandi
    Hamid Zandi over 4 years
    setMinimumSessionDuration is depricated
  • Dan Morenus
    Dan Morenus over 4 years
    @do01 That's right. Now sessions start as soon as your app is in the foreground.
  • Jonas Stawski
    Jonas Stawski about 4 years
    How about if the user hard closes the app and then re opens it. Is that considered a new session?
  • Evgeny Karkan
    Evgeny Karkan almost 3 years
    hey @ToddKerpelman I know you are Firebase wizard - could you please help with this question stackoverflow.com/questions/67882661/…