简体   繁体   中英

Android Google Analytics v2 manually manage session without using EasyTracker

I need to start and to stop a session at a specific hour.
In official documentation I have found only that I can start a new session :

// Called after a user successfully signs in to your app.
private void onSignIn() {
  ... // The rest of your onSignIn() code.
  myTracker.setStartSession(true); // Where myTracker is an instance of Tracker.
  myTracker.sendEvent("app_flow", "sign_in", "", null); // First activity of new session.
}

But I have no methods in API to stop the session or to change the session time out.
I already tried to set ga_sessionTimeout to 1 day but it didn't worked,
after ~8 minutes the session was closed even when the activity was still on the screen.I saw it on my Google Analytics dashboard's real-time overview.

Other ideas will be appreciated.

By default, Google Analytics will group hits that are received within 30 minutes of one another into the same session.

My goal was to keep the session alive till some event happen,
therefore I decided to implement Heartbeat mechanism.
That will send event every X minutes to keep the session alive.

It solved my problem.

PS : I discovered another thread with same solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM