3

我正在尝试为 Google Analytics 设置 5 个自定义变量,如下所示:

<script>
    //<![CDATA[
    var _gaq=[["_setAccount","UA-XXXXXXXXX-X"],["_trackPageLoadTime"]];
    _gaq.push(['_setCustomVar', 1, 'categories', 'News', 3]);   
    _gaq.push(['_setCustomVar', 2, 'tags', 'something, another, passbook, iphone, ipod, ios6, insider, egift, more things, some other stuff', 3]);  
    _gaq.push(['_setCustomVar', 3, 'productcount', 0, 3]);  
    _gaq.push(['_setCustomVar', 4, 'isvideo', 'false', 3]);
_gaq.push(['_trackPageview']);

(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
s.parentNode.insertBefore(g,s)}(document,"script"));
//]]>

</script>

我想我已经遵守了所有规则,在调用 trackPageView 之前添加了不超过 5 个自定义变量,但它们仍然没有出现在 Google Analytics 中。

4

1 回答 1

5

可能性:

  • 自定义变量可能会落后于 _trackPageview 在 GA UI 中的显示。(来源#1)
  • 如果您使用的是 ga_debug.js,您可以在控制台中看到回击的内容。(来源#2)
  • 您正在使用 CustomVar(2) 接近 128 的自定义变量长度。由于这是测试数据,请确保您的真实数据不会超过。(来源#3)
  • Eduardo 是正确的,0 与“0”导致 CustomVar(3) 不触发。(来源 #2 和测试)
  • _trackPageLoadTime 已弃用(来源 #2+3 和测试)

链接/参考:

  1. 掌握 Google Analytics(分析)自定义变量
  2. 谷歌分析调试器
  3. 官方 Google Analytics 自定义变量文档

更新了调试器演示页面中的片段:

(从不是 localhost 或 file:// 的东西提供服务)

<html><head><title>Demo</title><script>

var _gaq=[["_setAccount","UA-XXXXXXXXX-X"]];
_gaq.push(['_setCustomVar', 1, 'categories', 'News', 3]);   
_gaq.push(['_setCustomVar', 2, 'tags', 'something, another, passbook, iphone, ipod, ios6, insider, egift, more things, some other stuff', 3]);  
_gaq.push(['_setCustomVar', 3, 'productcount', '0', 3]);  
_gaq.push(['_setCustomVar', 4, 'isvideo', 'false', 3]);
_gaq.push(['_trackPageview']);
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
s.parentNode.insertBefore(g,s)}(document,"script"));

</script></head><body><h1>Open your console</h1></body></html>
于 2012-09-19T22:00:46.173 回答