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
}
https://www.google-analytics.com/collect
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.