Reputation: 88277
I am using the measurement protocol for my Tizen TV application since I cannot use the JS (requires a domain name) nor Android/iOS SDKs.
I am sending
{
v: 1,
tid: GA_TRACKING_ID,
cid: data.deviceId,
t: 'screenview',
dh: 'something.com',
dp: encodeURIComponent($location.path()),
cd: transition.to().title + ($stateParams.gaTitle ? ' (' + $stateParams.gaTitle + ')' : '') || 'Unknown',
an: 'XXX',
'ga:mobileDeviceModel': data.deviceModel
}
To https://www.google-analytics.com/collect
But the screen times seem off its always in the seconds eg. 30s etc. I tested staying on page for a long time but it does not seem correctly reflected. I guess its because I only send this hit once and theres no way for Google to know when it stopped? Is there a way to fix this?
Upvotes: 10
Views: 880
Reputation: 13495
First you need to decide on the session timeout (Admin->property->tracking.js) the default of 30 minutes means you will need to generate hits at intervals bellow 30 minutes to prevent new hits from being in a new session.
Then you need to make sure hits are frequent enough and include their current page/screen names, for example:
{ // start video
v: 1,
tid: GA_TRACKING_ID,
cid: data.deviceId,
t: 'screenview',
dh: 'something.com',
dp: encodeURIComponent($location.path()),
cd: transition.to().title + ($stateParams.gaTitle ? ' (' + $stateParams.gaTitle + ')' : '') || 'Unknown',
an: 'XXX',
'ga:mobileDeviceModel': data.deviceModel
}
{ // < 30 minutes later
v: 1,
tid: GA_TRACKING_ID,
cid: data.deviceId,
t: 'event',
ec: 'Inactivity',
ea: 'Watching Video',
el: ..video name..,
ev: 28,
ni: 0, // count as interaction, ni=1 are ignored in time calculations
dh: 'something.com',
dp: encodeURIComponent($location.path()),
cd: transition.to().title + ($stateParams.gaTitle ? ' (' + $stateParams.gaTitle + ')' : '') || 'Unknown',
an: 'XXX',
'ga:mobileDeviceModel': data.deviceModel
}
{ // user does something (can wait 30 minutes more before a new ni event)
v: 1,
tid: GA_TRACKING_ID,
cid: data.deviceId,
t: 'event',
ec: 'Activity',
ea: 'Volume Adjustment Down',
el: ..video name..,
ev: 5,
ni: 0,
dh: 'something.com',
dp: encodeURIComponent($location.path()),
cd: transition.to().title + ($stateParams.gaTitle ? ' (' + $stateParams.gaTitle + ')' : '') || 'Unknown',
an: 'XXX',
'ga:mobileDeviceModel': data.deviceModel
}
{ // user goes to new screen (also calculated as the end of screen time)
v: 1,
tid: GA_TRACKING_ID,
cid: data.deviceId,
t: 'screenview',
dh: 'something.com',
dp: encodeURIComponent($location.path()),
cd: 'somewhere else',
an: 'XXX',
'ga:mobileDeviceModel': data.deviceModel
}
If you have the ability to send on all exit events then you may want to use queue time on exit (or every 4 hours) to calculate for the session after all the data for the period is in.
Upvotes: 8
Reputation: 41
Google Analytics' session calculating is based on interaction from the user. If the user clicks, the session gets a heartbeat. If the user is watching a movie (TV e.g.) it wont be interacting with your application and the session stops
Take a look at this page https://www.optimizesmart.com/understanding-sessions-in-google-analytics/
Upvotes: 3