How does Firebase Analytics define a session?
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]
![Todd Kerpelman](https://i.stack.imgur.com/hzFUq.jpg?s=256&g=1)
Comments
-
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. over 7 yearsThanks 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 over 7 yearsThanks, Dan! I've update my answer to reflect your comments.
-
Todd Kerpelman over 7 yearsHi, 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 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 over 7 years@MichaelSotnikov It simply means a user has your app in the foreground on their device.
-
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 over 6 yearsCan you help me with this question please?
-
Hamid Zandi over 4 yearssetMinimumSessionDuration is depricated
-
Dan Morenus over 4 years@do01 That's right. Now sessions start as soon as your app is in the foreground.
-
Jonas Stawski about 4 yearsHow about if the user hard closes the app and then re opens it. Is that considered a new session?
-
Evgeny Karkan almost 3 yearshey @ToddKerpelman I know you are Firebase wizard - could you please help with this question stackoverflow.com/questions/67882661/…