0

We are making the switch to Universal Analytics, the code below defines the author in the new tracking code.

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-xxxxxx-x', 'example.com');
    ga('send', 'pageview', { 'dimension1': '<?=$author?>'});
</script>

The question is, if we have several authors, do we need to define them individually as a custom dimensions (1,2,3..etc) and pass each dimension via the pageview send?

Also, what about tracking events? For example, tracking errors on a form:

ga('send', 'Event', 'Signup Form', 'First Name', 'Error Code Desc', {'nonInteraction': 1}” 

Is this put in the tracking code too? Or in the code for the form?

4

2 回答 2

1

您不需要每个 autor 的自定义维度(您会很快用完自定义维度,自定义维度和指标只有 20 个插槽)。只需在“命中”范围内创建一个自定义维度“作者”(自定义定义->自定义维度界面中有一个包含命中、会话、访问者三个设置的下拉列表,作者是当前页面的属性,因此您选择了“命中” ) 并传递作者姓名。

事件用于跟踪不会导致浏览量或内容更改的交互,因此通常您会将它们放在一个 javascript 回调函数中,用于您想要跟踪的任何事件。您的示例看起来应该存储表单错误,因此它将进入该表单的(客户端)验证功能。只需确保在您的事件之前页面中的某处有一个跟踪器(对 ga('create') 的调用)(通常标准的浏览量跟踪代码已经创建了一个跟踪器对象,因此这应该不是问题)。

于 2014-01-24T14:29:26.703 回答
0

因此,我快速阅读了有关此的 Google 文档https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets

据我所知,您需要将每个维度定义为自定义维度并发送它们。(我链接的页面底部)。

我不太确定关于表单上跟踪错误的第二个问题,我相信其他可能对此有所了解的人会有所帮助。

于 2014-01-24T13:45:23.047 回答