使用测量协议时,Google Analytics屏幕时间不准确

10

因为我无法使用JS(需要域名)或Android/iOS SDK,所以我正在为我的Tizen TV应用程序使用测量协议。

我正在发送:

{
        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秒等。我测试了很长时间停留在页面上,但它似乎没有正确反映。我猜这是因为我只发送了一次此命中(hit),谷歌无法知道何时停止?有办法解决这个问题吗?


你能否提供更多关于问题的见解,比如你是如何发送数据的,以及你期望以哪种方式得到返回结果。更多相关代码将有助于解决问题。 - Ahmad Baktash Hayeri
更新了我的原帖。但基本上我正在对https://www.google-analytics.com/collect 进行API调用。 - Jiew Meng
2个回答

8
首先,您需要决定会话超时时间(管理->属性->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
}

如果您有能力发送所有退出事件,那么您可能想在退出时(或每4小时)使用排队时间来计算该期间的会话数据。请参考排队时间。请注意保留HTML标记。

太棒了,我明天会试试看。但是我有一个问题。我的平均会话时间不应该至少达到30分钟吗?为什么我的会话时间都这么短呢? - Jiew Meng
@JiewMeng 您的会话时间是从第一次点击到最后一次点击,其中任何30分钟的间隙都会中断会话。因此,如果您导航2分钟,然后在某个地方停留40分钟,然后去其他地方,您将有一个由几个点击和两分钟组成的会话以及38分钟后的1次点击和0秒钟的另一个会话。但是,如果您希望会话显示为“停留”在同一屏幕/页面上,则还必须小心保持cd/dp/dh参数不变,即使您生成其他点击类型。 - lossleader
1
@JiewMeng 你也可以在hit builder上进行测试 https://ga-dev-tools.appspot.com/hit-builder/ 无论哪种方式,如果你使用“qt”,你可以一次为一个cid创建4小时的用户虚拟会话,然后在报告->受众->用户浏览器中查看。 - lossleader

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接