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?
Most Likely Cause: You do not have your Google Analytics code installed, you have the wrong code installed, or you have it installed incorrectly. Quick Fix: Always make sure that the correct code is installed for the account that you are in.
The Google Analytics Measurement Protocol allows developers to make HTTP requests to send raw user interaction data directly to Google Analytics servers. This allows developers to measure how users interact with their business from almost any environment.
You can't track Individual users Unfortunately, Google Analytics only allows to use a unique user ID and prohibits sending personal information, username or an IP address. So you can't really see and understand how specific users behave on your site and get valuable data.
Missing information. Many people will opt out of Google Analytics; they may also block cookies and/or switch off JavaScript which is how Google tracks the behaviour of visitors. Their activity is not tracked leading to under-reporting.
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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With