session count mismatch in GA and Flurry analytics in android app
I am developing an app which has 10 activities. I am integrating both Google and Flurry analytics in my app. For GA, I am maintaining a global tracker object which gets started in the launcher acitivity, and gets stopped when app is closed. For Flurry, I am starting session in the onCreate of each activity and stopping the session in onStop of each activity.
Now, when I use my app many times, and when see the stats on开发者_C百科 both GA and Flurry profiles I see that GA is showing counts of Visits too high whereas Flurry is showing very low count of visits.
I guess that Flurry does not start a new session if session is stopped by the app, and we restart the app withing 10 seconds. Is this the reason of having this difference between counts or there may be something wrong with the code.
First of all, what is the launchmode of your application? http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
If you are allowing multiple instances then it is possible that users could hit the same launcher activity multiple times within the same session which Google may be treating as extra sessions.
Secondly, onStop() is not guaranteed to be called. onPause is actually the last state that is guaranteed to occur: http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle That probably doesn't have any bearing on this because session count is done off of the open call but it is something interesting to note regardless.
An interesting test would be to fire an "app launched" event in both Flurry and GA when the app first comes up. Then you'll have a datapoint that is much less fuzzy than sessions to compare the two and see which is over or under reporting.
Move your Flurry onStartSession
calls to onStart
.
onCreate
is only ever called once, whereas every time the activity comes to the foreground it runs through onStart
. Flurry treats activities in a similar fashion to a stack. onStartSession
puts an activity on the stack and onEndSession
pops it off. When there are none left after a certain timeout, the SDK effectively ends the session.
With your onStartSession
calls in onCreate
, you're getting a valid session with the creation of every activity, but if you ever go back to that activity your session is ending. Moving onStartSession
to onStart
fixes this.
精彩评论