Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use trackPageview in Google Analytics?

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.

like image 434
user1355300 Avatar asked Apr 25 '12 05:04

user1355300


People also ask

How do I add a pageview in Google Analytics?

First, create a new Google Analaytics tag, or copy an existing one, and set its type to “Pageview”, then check “Enable overriding settings in this tag”. Expand “More Settings” and “Fields to Set”. Finally, add 2 new fields and put “page” and “title” for field names.

How do you find average time on page in Google Analytics?

From your Google Analytics dashboard, navigate to Behavior → Site Content → Landing Pages. Here, you can find the average session duration for each of your pages.

How does Google Analytics track virtual page views?

You can see the virtual pageviews in 'All Pages' and 'Content Drilldown' reports (under Behavior > Site Content) in your Google Analytics account along with the real page views. Note: If you are heavily using virtual pageviews then create a separate view, just to track them.


1 Answers

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

like image 115
Will Klein Avatar answered Oct 10 '22 02:10

Will Klein