我正在为我的 Tizen TV 应用程序使用测量协议(protocol),因为我不能使用 JS(需要域名)或 Android/iOS SDK。
我要发送
{
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
但是屏幕时间似乎总是以秒为单位,例如。 30 秒等。我测试了长时间停留在页面上,但似乎没有正确反射(reflect)。我猜是因为我只发送一次此点击,而 Google 无法知道它何时停止?有没有办法来解决这个问题?
最佳答案
首先你需要决定 session 超时(Admin->property->tracking.js) 默认的 30 分钟意味着您需要以低于 30 分钟的间隔生成匹配,以防止新匹配出现在新 session 中。
然后您需要确保点击足够频繁并包括他们当前的页面/屏幕名称,例如:
{ // 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
}
如果您能够发送所有退出事件,那么您可能需要使用 queue time在退出时(或每 4 小时)计算该时段的所有数据后的 session 。
关于javascript - 使用 Measurement Protocol 时 Google Analytics 屏幕时间不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46193842/