Jie*_*eng 10 javascript google-analytics
我正在为我的Tizen TV应用程序使用测量协议,因为我不能使用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
}
Run Code Online (Sandbox Code Playgroud)
至 https://www.google-analytics.com/collect
但屏幕时间似乎总是在几秒钟之内.30s等我测试了很长一段时间在页面上停留但似乎没有正确反映.我猜它是因为我只发了一次这个命中,谷歌没办法知道它什么时候停止了?有没有办法来解决这个问题?
首先,您需要决定会话超时(Admin-> property-> tracking.js),默认值为30分钟意味着您需要以30分钟之间的间隔生成匹配,以防止新的匹配进入新会话.
然后你需要确保点击频率足够频繁并包括他们当前的页面/屏幕名称,例如:
{ // 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
}
Run Code Online (Sandbox Code Playgroud)
如果您能够发送所有退出事件,那么您可能希望在退出时(或每4小时)使用队列时间来计算该期间的所有数据所在的会话.