简体   繁体   English

如何在Google Analytics中使用trackPageview?

[英]How to use trackPageview in Google Analytics?

I need help in configuring the _trackPageview in the Google Analytics. 我需要帮助在Google Analytics中配置_trackPageview 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文档,我需要在下载链接中使用以下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? 我是否需要在Google Analytics帐户中配置任何内容? Thanks. 谢谢。

That should work, and you shouldn't need to configure anything in Analytics. 这应该有效,您不需要在Analytics中配置任何内容。 You will not see the events appear in the Analytics account immediately. 您不会立即在Google Analytics帐户中看到这些事件。 I'd give it 24-48 hours to start showing up. 我会给它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. 跟进并确认事件正在注册非常重要。

Edit: More info regarding _trackPageview vs _trackEvent... 编辑:有关_trackPageview vs _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. 我的建议是,如果您要跟踪许多不同的可下载文件,请查看_trackEvent。 If you only have one or two files to track, _trackPageview is definitely suitable. 如果您只有一个或两个要跟踪的文件,_trackPageview绝对适合。 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将允许您按类别(文件下载),操作(超链接点击)和标签(地图)进行跟踪,如果您对此感兴趣,这可能会更有用下载作为一个整体。

_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

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. 如果你看到它出现在“热门活跃页面”中,那么你就可以去,镀金和金色。

You can also use the debug version of ga.js to diagnose errors. 您还可以使用ga.js的调试版本来诊断错误。 It prints things like "Invalid tracking code" and so on to the Javascript console. 它会将诸如“无效的跟踪代码”等内容打印到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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM