繁体   English   中英

此analytics.js函数的旧版ga.js等效项是什么?

[英]What is the legacy ga.js equivalent of this analytics.js function?

在analytics.js中,您可以像这样设置自定义属性:

ga('set', 'foo', 'bar');

该如何做为较旧的旧版本?

编辑

我基本上是想做到这一点:

var ua = navigator.userAgent || navigator.vendor || window.opera;
ga('set', 'dimension1',(ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1) ? 'Facebook' : 'None');

dimension1是我创建“自定义维度”时从分析仪表板上获得的内容。 按照此处的指示进行操作并不重要,但仍然如此( http://oko.uk/blog/tracking-inapp-browsers )。

所以我不确定这是否算作自定义变量...

您可以使用函数_setCustomVar(index, name, value, opt_scope)创建自定义变量,如下所示-

 _gaq.push(['_setCustomVar',
      1,                   // This custom var is set to slot #1.  Required parameter.
      'Items Removed',     // The name acts as a kind of category for the user activity.  Required parameter.
      'Yes',               // This value of the custom variable.  Required parameter.
      2                    // Sets the scope to session-level.  Optional parameter.
   ]);
 _gaq.push(['_trackEvent',
      'Shopping', // category of activity
      'Item Removal', // Action
   ]);

请查看以下链接以了解更多详细信息https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables

我认为Google甚至不再支持此功能。

_gaq.push(['_setCustomVar', category, action, label]); 您可以在文档中阅读更多内容。 https://developers.google.com/analytics/devguides/collection/gajs/#one-push-multiple-commands

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM