此行可以在 Google Analytics Custom Variable Documentation 中找到
You have up to 5 simultaneous custom variables for use in a single request (e.g. pageview or event call). The sum of all your custom varaiables cannot exceed 5 in any given request (i.e. you cannot have 5 visitor and 5 session custom variables set simultaneously).
这是否是 javascript/beacon 的限制和/或 GA 在免费版 Google Analytics(分析)中汇总事件的方式的限制?
用代码改写一下,如果我使用的是支付 GA Premium 的帐户,这会起作用吗?
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_setCustomVar', 1, 'Foo', "Bar", 1]);
_gaq.push(['_setCustomVar', 2, 'Biz', "Baz", 2]);
_gaq.push(['_setCustomVar', 3, 'Ugg', "Bot", 3]);
_gaq.push(['_setCustomVar', 4, 'Big', "Bug", 1]);
_gaq.push(['_setCustomVar', 5, 'Sun', "Tin", 2]);
_gaq.push(['_setCustomVar', 6, 'Hor', "Ton", 3]);
_gaq.push(['_setCustomVar', 7, 'Saw', "Who", 1]);
_gaq.push(['_setCustomVar', 8, 'Dis', "Dat", 2]);
_gaq.push(['_setCustomVar', 9, 'Who', "Der", 3]);
_gaq.push(['_trackPageview']);
_gaq.push(["_trackEvent", "cat", "action", "lbl", 0, true]);
或者我必须像这样构造上面的代码:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_setCustomVar', 1, 'Foo', "Bar", 1]);
_gaq.push(['_setCustomVar', 2, 'Biz', "Baz", 2]);
_gaq.push(['_setCustomVar', 3, 'Ugg', "Bot", 3]);
_gaq.push(['_setCustomVar', 4, 'Big', "Bug", 1]);
_gaq.push(['_setCustomVar', 5, 'Sun', "Tin", 2]);
_gaq.push(['_trackPageview']);
_gaq.push(['_setCustomVar', 6, 'Hor', "Ton", 3]);
_gaq.push(['_setCustomVar', 7, 'Saw', "Who", 1]);
_gaq.push(['_setCustomVar', 8, 'Dis', "Dat", 2]);
_gaq.push(['_setCustomVar', 9, 'Who', "Der", 3]);
_gaq.push(["_trackEvent", "cat", "action", "lbl", 0, true]);
最佳答案
是的,您最多可以将 50 个自定义变量附加到 Google Analytics Premium。因此,针对 Google Analytics Premium 客户的声明应如下所示:
You have up to 50 simultaneous custom variables for use in a single request (e.g. pageview or event call). The sum of all your custom varaiables cannot exceed 50 in any given request (i.e. you cannot have 50 visitor and 50 session custom variables set simultaneously).
正确的做法是第一种
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_setCustomVar', 1, 'Foo', "Bar", 1]);
_gaq.push(['_setCustomVar', 2, 'Biz', "Baz", 2]);
_gaq.push(['_setCustomVar', 3, 'Ugg', "Bot", 3]);
_gaq.push(['_setCustomVar', 4, 'Big', "Bug", 1]);
_gaq.push(['_setCustomVar', 5, 'Sun', "Tin", 2]);
_gaq.push(['_setCustomVar', 6, 'Hor', "Ton", 3]);
_gaq.push(['_setCustomVar', 7, 'Saw', "Who", 1]);
_gaq.push(['_setCustomVar', 8, 'Dis', "Dat", 2]);
_gaq.push(['_setCustomVar', 9, 'Who', "Der", 3]);
_gaq.push(['_trackPageview']);
_gaq.push(["_trackEvent", "cat", "action", "lbl", 0, true]);
请注意,付费版和免费版的 JavaScript 代码是相同的。因此,如果您尝试在 Google Analytics 免费版中执行此操作,它看起来会起作用,但处理后端将忽略 5 以上的额外变量,除非您有 Google Analytics 高级版。
有关 Google Analytics Premium 的更多信息
关于google-analytics - 我可以使用 Google Analytics Premium 将 "attach"5 个以上的自定义变量添加到同一个 _trackPageview 中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12806819/