javascript 如何在 Google Analytics 中使用 trackPageview?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10309726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use trackPageview in Google Analytics?
提问by user1355300
I need help in configuring the _trackPageviewin the Google Analytics. I want to track how many times a file has been downloaded. According to Google Analytics documentation I need to use the following onClick event in the download links.
我需要在Google Analytics中配置_trackPageview 的帮助。我想跟踪一个文件被下载了多少次。根据 Google Analytics 文档,我需要在下载链接中使用以下 onClick 事件。
<a href="http://www.example.com/files/map.pdf"
onClick="javascript: _gaq.push(['_trackPageview', '/downloads/map']);">
But I could not find any information that after adding this, where I can see the download stats for this link? Do I need to configure anything in my Analytics account? Thanks.
但是我找不到任何信息,在添加这个之后,我在哪里可以看到这个链接的下载统计信息?我需要在我的 Analytics 帐户中配置任何内容吗?谢谢。
采纳答案by Will Klein
That should work, and you shouldn't need to configure anything in Analytics. You will not see the events appear in the Analytics account immediately. I'd give it 24-48 hours to start showing up.
这应该可行,而且您不需要在 Analytics 中配置任何内容。您不会立即看到事件出现在 Analytics 帐户中。我会给它 24-48 小时开始出现。
All clicks should be tracked from when you install the code. It may show up under Top Content, or you could filter visited pages by a partial URL.
应从安装代码时开始跟踪所有点击。它可能显示在热门内容下,或者您可以通过部分 URL 过滤访问过的页面。
Because of the delay inherent to Analytics, it's not uncommon to second-guess yourself when you try a new tracking technique. It's important to follow up and confirm the events are registering.
由于 Analytics 固有的延迟,当您尝试新的跟踪技术时,经常会自我怀疑。跟进并确认事件正在注册非常重要。
Edit: More info regarding _trackPageview vs _trackEvent...
编辑:有关 _trackPageview 与 _trackEvent 的更多信息...
_trackPageview: "Google Analytics' _trackPageview is a function for use on ga.js tracked sites that allows you to track events on your site that do not generate a pageview."
_trackPageview:“Google Analytics 的 _trackPageview 是一种用于 ga.js 跟踪网站的功能,允许您跟踪网站上不产生综合浏览量的事件。”
_trackEvent: "Event Tracking is a method available in the ga.js tracking code that you can use to record user interaction with website elements, such as a Flash-driven menu system."
_trackEvent:“事件跟踪是 ga.js 跟踪代码中提供的一种方法,可用于记录用户与网站元素的交互,例如 Flash 驱动的菜单系统。”
My suggestion is that if you have a number of different downloadable files that you want to track, look into _trackEvent. If you only have one or two files to track, _trackPageview is definitely suitable. My thought is that when you have a larger number of files to track, _trackEvent will let you track by category (file download), action (hyperlink click), and label (map), which may be more useful if you're interested in downloads as a whole.
我的建议是,如果您要跟踪许多不同的可下载文件,请查看 _trackEvent。如果你只有一两个文件要跟踪,_trackPageview 绝对适合。我的想法是,当您要跟踪的文件数量较多时,_trackEvent 会让您按类别(文件下载)、操作(点击超链接)和标签(地图)进行跟踪,如果您有兴趣,这可能更有用整体下载。
_trackEvent is also ad hoc in that whatever you code you write should auto-generate the corresponding report items without any configuration in Google Analytics.
_trackEvent 也是临时的,因为无论您编写什么代码,都应该自动生成相应的报告项,而无需在 Google Analytics 中进行任何配置。
More info (above quotes taken from these pages):
更多信息(以上引用自这些页面):
_trackPageview: http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55597
_trackPageview:http: //support.google.com/googleanalytics/bin/answer.py?hl =zh-CN& answer=55597
_trackEvent: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
_trackEvent:https: //developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
回答by Tom Hartman
If you want to make sure your tracking is working but don't want to wait 24-48 hours then go to the Real-Time (beta) tab in the Google Analytics sidebar.
如果您想确保您的跟踪工作正常但又不想等待 24-48 小时,请转到 Google Analytics 侧栏中的实时(测试版)选项卡。
Visit the website on another tab and, once you see that the 'Right now' indicator shows your presence, click on your download link. If you see it show up in the 'Top Active Pages' then you're good to go, gilded and golden.
在另一个选项卡上访问该网站,一旦您看到“现在”指示器显示您的存在,请单击您的下载链接。如果您看到它出现在“热门活动页面”中,那么您就可以开始使用了,镀金的和金色的。
回答by David Tinker
You can also use the debug version of ga.js to diagnose errors. It prints things like "Invalid tracking code" and so on to the Javascript console.
您还可以使用 ga.js 的调试版本来诊断错误。它将诸如“无效的跟踪代码”等内容打印到 Javascript 控制台。
Search for "Debugging with ga_debug.js" on this page:
在此页面上搜索“使用 ga_debug.js 进行调试”:
https://developers.google.com/analytics/resources/articles/gaTrackingTroubleshooting
https://developers.google.com/analytics/resources/articles/gaTrackingTroubleshooting