How to use trackPageview in Google Analytics?

18,675

Solution 1

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 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: "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.com/googleanalytics/bin/answer.py?hl=en&answer=55597

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

Solution 2

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.

Share:
18,675
user1355300
Author by

user1355300

Updated on June 16, 2022

Comments

  • user1355300
    user1355300 almost 2 years

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