Google Analytics自定义页面变量未显示在gif请求中

时间:2012-10-03 13:42:01

标签: javascript google-analytics

所以我在页面上有以下javascript:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<our account number>']);
_gaq.push('_setCustomVar',1,'page_type','main', 3);
_gaq.push(['_trackPageview']);

(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

但是,如果我查看网络流量,我会看到__utm.gif的一个请求,但未设置utme参数,正如我预期的那样。

1 个答案:

答案 0 :(得分:4)

您仍然需要方括号:(google custom vars

 _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.
   ]);
相关问题