最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use trackPageview in Google Analytics? - Stack Overflow

programmeradmin3浏览0评论

I need help in configuring the _trackPageview in 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.

<a href=".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.

I need help in configuring the _trackPageview in 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.

<a href="http://www.example./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.

Share Improve this question edited Apr 25, 2012 at 12:23 T. Junghans 11.7k8 gold badges54 silver badges77 bronze badges asked Apr 25, 2012 at 5:16 user1355300user1355300 4,98718 gold badges50 silver badges72 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

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.

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.

Because of the delay inherent to Analytics, it's not unmon 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: "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."

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

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 is also ad hoc in that whatever you code you write should auto-generate the corresponding report items without any configuration in Google Analytics.

More info (above quotes taken from these pages):

_trackPageview: http://support.google./googleanalytics/bin/answer.py?hl=en&answer=55597

_trackEvent: https://developers.google./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.

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. It prints things like "Invalid tracking code" and so on to the Javascript console.

Search for "Debugging with ga_debug.js" on this page:

https://developers.google./analytics/resources/articles/gaTrackingTroubleshooting

发布评论

评论列表(0)

  1. 暂无评论