Search code examples
sessiongoogle-analyticsmeasurement-protocol

Google Analytics session timeout even though timeout set at 1hrs?


I have set my session timeout at 1hr

enter image description here

I am using the measurement API since its a Samsung Tizen TV application and I cannot use the official Web/Android/iOS SDKs.

I am sending

var params = {
      v: 1,
      tid: GA_TRACKING_ID,
      cid: data.deviceId,
      t: 'pageview',
      dh: '...',
      dp: encodeURIComponent($location.path()),
      cd: transition.to().title + ($stateParams.gaTitle ? ' (' + $stateParams.gaTitle + ')' : '') || 'Unknown',
      an: '...',
      'ga:mobileDeviceModel': data.deviceModel
    };

And every 10 mins, I am sending

var params = {
    v: 1,
    tid: GA_TRACKING_ID,
    cid: data.deviceId,
    t: 'event',
    ec: 'RefreshToken',
    ea: 'Starting',
    el: '',
    ev: '',
    ni: 1,
    an: '...',
    'ga:mobileDeviceModel': data.deviceModel
  };

To refresh my application token and at the same time, an attempt to extend my session. It seems like this 2nd event is not tracked in my GA dashboard, I dont see it in Realtime events nor Behaviour > Events after 1 day.

Even if the event to "extend" session is not working, shouldn't my session time be ~1hr since the timeout is that time? And I did not manually end the session.

UPDATE

enter image description here

Notice there are events <10 mins ago, but there are 0 users online, even though my browser is still online


Solution

  • ev cant be a string:

    ev: '',
    

    must be a number (or omitted):

    ev: 10,
    

    (the event values now corresponds to the number of idle/keep-alive minutes)

    User Explorer test user

    turn off ni

    GA appears to be calculating sessions purely on interactive hits, so ni unfortunately wont work and should be omitted or disabled:

    ni: 0,
    

    User Explorer test user with an interactive event

    dh, dp, cd should be present for filtered views

    These are optional in the event context but you should use them to match the previous page or screen. Otherwise, you will not be able to use page dimensions in the event reports or build precise filtered views as you have more data.