How to use trackPageview in Google Analytics?

I need help setting up _trackPageview in Google Analytics. I want to track how many times the file was downloaded. According to the Google Analytics documentation, I need to use the following onClick event in download links.

<a href="http://www.example.com/files/map.pdf" onClick="javascript: _gaq.push(['_trackPageview', '/downloads/map']);"> 

But I could not find any information, which after adding this, where can I see the download statistics for this link? Do I need to configure anything in my Google Analytics account? Thanks.

+7
source share
3 answers

This should work, and you don’t need to configure anything in Google Analytics. You won’t see events appearing in your Analytics account right away. I would give 24-48 hours to start showing.

All clicks should be monitored from the time the code was installed. It can be displayed in the "Top Content" section or you can filter the pages you visit using a partial URL.

Due to the delays inherent in Analytics, you often need to guess yourself when you try to use a new tracking technique. It is important to monitor and confirm that events are being recorded.

Edit: More information about _trackPageview vs _trackEvent ...

_trackPageview: "Google Analytics" _trackPageview is a feature for use on ga.js monitored sites that allows you to track events on your site that do not generate pageviews.

_trackEvent: "Event tracking is a method available in the ga.js tracking code that you can use to record user interactions with website elements, such as a flash menu menu system."

My suggestion is that if you have several different downloads that you want to track, take a look at _trackEvent. If you only have one or two files to track, then _trackPageview is definitely suitable. My thought is that when you have a large number of files to track, _trackEvent will allow you to track by category (file download), action (hyperlink) and label (map), which may be more useful if you are interested in the downloads in general .

_trackEvent is also ad hoc in that no matter what code you write, you should automatically generate the appropriate report elements without any configuration in Google Analytics.

Additional information (the above quotes from these pages):

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

_trackEvent: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

+5
source

If you want your tracking to work, but don’t want to wait 24-48 hours, go to the “Real-time” (beta) tab in the sidebar of Google Analytics.

Visit the website on a different tab, and as soon as you see the “Right Now” indicator is showing your presence, click the download link. If you see this being displayed in the "Top Active Pages", then you can go, gilding and golden.

+3
source

You can also use the debug version of ga.js to diagnose errors. It prints things like "Invalid tracking code," etc. On the Javascript console.

Find "Debugging with ga_debug.js" on this page:

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

0
source

All Articles