I have Google Analytics setup on my site, and it is definitely recording page views. But I have added some code to call pageTracker._trackEvent(category, action, label, value)
, and it is not recording those hits or showing them in the reports.
我的网站上有Google Analytics设置,它肯定会记录网页浏览量。但是我添加了一些代码来调用pageTracker._trackEvent(类别,操作,标签,值),并且它没有记录这些命中或在报告中显示它们。
BTW, yes, I have waited for over 24hrs to see if the hits are in the reports.
顺便说一句,是的,我已经等了24个多小时才看看这些热门是否在报告中。
I have used the standard Google script include as well as the technique mentioned here. Neither one seems to help the _trackEvent()
problem.
我使用了标准的Google脚本包括以及这里提到的技术。似乎没有人帮助_trackEvent()问题。
Can anyone give me some advice on how to track down what's going wrong? I'd be happy to post code examples if you let me know what parts are important.
谁能给我一些关于如何追踪出错的建议?如果您让我知道哪些部分很重要,我会很乐意发布代码示例。
Thanks.
4 个解决方案
#1
The problem was the values that I was putting in the final argument, the "value" parameter.
问题是我在最终参数中放入的值,即“value”参数。
pageTracker._trackEvent(category, action, label, value)
I was passing non-integer strings to the "value" parameter:
我将非整数字符串传递给“value”参数:
pageTracker._trackEvent("UserAction", "ShowHelp", "Page", "http://mysite/UrlGoesHere");
but the docs say it needs to be an integer value.
但是文档说它需要是一个整数值。
pageTracker._trackEvent("UserAction", "ShowHelp", "http://mysite/UrlGoesHere", 1);
I posed the question on Google Help Forums here.
我在Google帮助论坛上提出了这个问题。
And here is a link to the Event Tracking docs
这是一个指向事件跟踪文档的链接
Thanks for the help Török
感谢Török的帮助
#2
Similarly, label can not be an integer or the _trackEvent function fails silently.
同样,label不能是整数,否则_trackEvent函数会无声地失败。
pageTracker._trackEvent('VLP', 'click-out', 12345);
Fixed as
pageTracker._trackEvent('VLP', 'click-out', '12345');
#3
Updated Answer
This question is still getting a lot of pageviews. I feel like the current visitors are facing a new problem that the other answers don't address.
这个问题仍然得到很多网页浏览量。我觉得当前的访客正面临一个新的问题,其他答案没有解决。
New Analytics Means New APIs
新分析意味着新的API
If you are using the "Universal Analytics" snippet which is Google's new system they are trying to transition everyone over to. Some of the APIs have changed including event tracking.
如果您使用的是Google新系统的“Universal Analytics”代码段,那么他们正试图将所有人转移到。一些API已经改变,包括事件跟踪。
Make sure you are using this:
确保您使用此:
ga('send', 'event', category, action, label, value);
Instead of this:
而不是这个:
_gaq.push(['_trackEvent', category, action, label, value]);
For event tracking.
用于事件跟踪。
Here is a thorough blog post on the subject http://blog.tylerbuchea.com/tracking-events-in-googles-new-universal-analytics/
这是一篇关于该主题的完整博客文章http://blog.tylerbuchea.com/tracking-events-in-googles-new-universal-analytics/
And here is the new documentation from Google https://developers.google.com/analytics/devguides/collection/analyticsjs/events
以下是Google提供的新文档https://developers.google.com/analytics/devguides/collection/analyticsjs/events
#4
it is not recording those hits or showing them in the reports.
它没有记录那些命中或在报告中显示它们。
Events have no effect on page views and do not appear on regular reports. Events have a seperate interface at Content / Events. If you'd like to track the things you specified as events like regular hits, better use the trackPageview
method instead.
事件对页面视图没有影响,也不会出现在常规报告中。事件在Content / Events中具有单独的界面。如果您想跟踪指定为常规命中等事件的内容,请更好地使用trackPageview方法。
#1
The problem was the values that I was putting in the final argument, the "value" parameter.
问题是我在最终参数中放入的值,即“value”参数。
pageTracker._trackEvent(category, action, label, value)
I was passing non-integer strings to the "value" parameter:
我将非整数字符串传递给“value”参数:
pageTracker._trackEvent("UserAction", "ShowHelp", "Page", "http://mysite/UrlGoesHere");
but the docs say it needs to be an integer value.
但是文档说它需要是一个整数值。
pageTracker._trackEvent("UserAction", "ShowHelp", "http://mysite/UrlGoesHere", 1);
I posed the question on Google Help Forums here.
我在Google帮助论坛上提出了这个问题。
And here is a link to the Event Tracking docs
这是一个指向事件跟踪文档的链接
Thanks for the help Török
感谢Török的帮助
#2
Similarly, label can not be an integer or the _trackEvent function fails silently.
同样,label不能是整数,否则_trackEvent函数会无声地失败。
pageTracker._trackEvent('VLP', 'click-out', 12345);
Fixed as
pageTracker._trackEvent('VLP', 'click-out', '12345');
#3
Updated Answer
This question is still getting a lot of pageviews. I feel like the current visitors are facing a new problem that the other answers don't address.
这个问题仍然得到很多网页浏览量。我觉得当前的访客正面临一个新的问题,其他答案没有解决。
New Analytics Means New APIs
新分析意味着新的API
If you are using the "Universal Analytics" snippet which is Google's new system they are trying to transition everyone over to. Some of the APIs have changed including event tracking.
如果您使用的是Google新系统的“Universal Analytics”代码段,那么他们正试图将所有人转移到。一些API已经改变,包括事件跟踪。
Make sure you are using this:
确保您使用此:
ga('send', 'event', category, action, label, value);
Instead of this:
而不是这个:
_gaq.push(['_trackEvent', category, action, label, value]);
For event tracking.
用于事件跟踪。
Here is a thorough blog post on the subject http://blog.tylerbuchea.com/tracking-events-in-googles-new-universal-analytics/
这是一篇关于该主题的完整博客文章http://blog.tylerbuchea.com/tracking-events-in-googles-new-universal-analytics/
And here is the new documentation from Google https://developers.google.com/analytics/devguides/collection/analyticsjs/events
以下是Google提供的新文档https://developers.google.com/analytics/devguides/collection/analyticsjs/events
#4
it is not recording those hits or showing them in the reports.
它没有记录那些命中或在报告中显示它们。
Events have no effect on page views and do not appear on regular reports. Events have a seperate interface at Content / Events. If you'd like to track the things you specified as events like regular hits, better use the trackPageview
method instead.
事件对页面视图没有影响,也不会出现在常规报告中。事件在Content / Events中具有单独的界面。如果您想跟踪指定为常规命中等事件的内容,请更好地使用trackPageview方法。