Can't configure 'begin_session' to work properly

User session is not counted properly, and here is my flow:

1. I put countly in offline mode till user will log in

2. When user logs in i am triggering disable_offline_mode and begin_session

3. when user logs out i am triggering end_session and enable_offline_mode

 

Also when i go to visitors -> visitors profile -> select user i am testing -> open its profile

User graph is not showing anything if 'today' is selected, only 'history' is showing last user activity. Users sessions count is not incremented. Only difference i notice is that last logged in user is on top of the list in user profiles list. and also SESSION HISTORY shows correct date when user last time logged in.

Also what is flow to use session_duration? I thought it was to count session duration yet in docs i found that it is to extend session. And i am confused when to use it.

Also what is noHeartBeat and why there is no examples using it? Yet it is in section about tracking sessions. 

 

Also can you explain how session tracking works? i mean what conditions should be met to count as another session? in my case where different users will use same PC to log in, how to make it count as different sessions

0

Comments

17 comments
  • Official comment

    Hello Andrii,

    Thanks for reaching out.

    You don't need to manually control the session, just let the SDK do everything. You should just call track_sessions and that's it. You should disable_offline mode only when user logs in and it will handle the session itself.

    Comment actions Permalink
  • I tried that also and well for some reason sessions are not counted correctly, if i am constantly logging in and logging out session count is not incremented. also on chart if i select today its empty. i think i have done something wrong.

    0
    Comment actions Permalink
  • Hello,

    Can you please provide a code snippet showing how you implemented it?

    0
    Comment actions Permalink
  • i'm not sure there is much of the code. 

     

    First scenario i've tried is init track session after Countly was loaded but enabling offline mode and after user submits sign in form i run this code below:

    Countly.q.push(['track_sessions']);
    Countly.q.push(['disable_offline_mode', userId]);

    Second scenario is when i enable offline mode but not triggering track_sessions, i am triggering 

    Countly.q.push(['begin_session']);

    and if user clicks logout i am triggering 

    Countly.q.push(['end_session']);
    Countly.q.push(['enable_offline_mode']);

    Both seems to see user but session count is not incremented. user always has 1 session count

     

     

    0
    Comment actions Permalink
  •  Also, why total session always shows 0 for this user? i am logging in and logged out like 10 times in row yet total sessions is always 0. how this works? what should i do to make this number increment?

     

     

    0
    Comment actions Permalink
  • Hello Andreii,

    One other possibility is session cookie, if you want control over session, you need to disable session cookie when initializing SDK.

    http://countly.github.io/countly-sdk-web/Countly.html#.init

    You can enable debug in SDK and see if there are begin_session=1 requests made to the server.

    0
    Comment actions Permalink
  • Well, i have settings as follows

    Countly.app_key = process.env.COUNTLY_APP_KEY;
    Countly.url = process.env.COUNTLY_DNS_SERVER;
    Countly.inactivity_time = 5;
    Countly.app_version = 0.0.1;
    Countly.use_session_cookie = false; // disbled cookies
    Countly.q.push(['enable_offline_mode']);
    Countly.q.push(['views']);
    Countly.q.push(['track_clicks']);
    Countly.q.push(['track_scrolls']);
    Countly.q.push(['track_errors']);
    Countly.q.push(['track_links']);
    Countly.q.push(['track_forms']);
    Countly.q.push(['collect_from_forms']);

    After i have added line with disabling session cookies, session count has incremented per 1 and stopped reacting. Meaning page refresh or re-login seems have no effect.

    Also in console i can see that request have as part of url ...com/i?begin_session=1&metrics=%7B%22_app_version%22%3A0.1%2C%22...

     

    Also seems it is working if i logout with current user and log in with different. If next time i log in with first user it seems to work and count properly. but if i log in/ log out with same user, sessions seems to count as single session. if that is by design than question can be considered closed and solved.

     

     

    0
    Comment actions Permalink
  • Hello Andreii,

    Yes, that is because of session cooldown, if a session is ended and started within 15 seconds, then it extends the same session and not create a new one, so page refresh should never create a new session.

    0
    Comment actions Permalink
  • One more thing i need to know, well that wrong time Countly shows about users. Meaning i log in in 2PM local time yet countly shows different time. I have asked our Dev OPS team and they said that Countly server is on Riga time zone(UTC/GMT +2 hours) )

    0
    Comment actions Permalink
  • Hello Andrii,

    You can change the time zone in the app configuration. Thanks :)

    0
    Comment actions Permalink
  • Hi, 

    I found only Default Country section, is it it?

    0
    Comment actions Permalink
  • Hello Andrii,

    It's the Time Zone option in the app settings. Thank you.

    0
    Comment actions Permalink
  • Got it thx, it is not clickable though, can it be because of my user rights?

    0
    Comment actions Permalink
  • If you can see it, you should be able to edit it as well. Please click on the Ellipsis symbol (three dots) on the top right side of that section and you'll see the edit option.

    0
    Comment actions Permalink
  • OMG, i feel embarrassed, thank you very much. Yes all good thank you

    0
    Comment actions Permalink
  • hey This is very good information to share .....FE

    0
    Comment actions Permalink
  • 192.168.l.l is an IP address used by many routers and modems as the default gateway. 192.168.1.1 address can be used by the users to gain the router admin access and configure their routers and networks.

    0
    Comment actions Permalink

Please sign in to leave a comment.