谷歌分析新版本用于设置自定义变量

时间:2014-02-03 11:08:03

标签: google-analytics google-analytics-api

这是我的新分析代码:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-000000-0', 'mysite.com');
  ga('send', 'pageview');

</script>

我在分析API中发现,我设置了一个自定义var:

_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.

]);

但变量&#34; _gaq&#34;不是什么,我在哪里放置这些代码? 我的分析就在标记之后

1 个答案:

答案 0 :(得分:1)

Universal Analytics没有.push它有ga()函数。

此外,Universal Analytics中没有自定义变量。在Universal Analytics中,我们会获得自定义维度和指标。

您的自定义变量与新的自定义维度几乎相同。

主要区别在于它们是在GA界面中设置的,而不是通过旧的.push函数的参数设置的。

ga('set','dimension1','Yes');

Set up or edit custom dimensions & metrics

相关问题