Articles in The '_trackPageview' Tag


February 24 2011

The Pros and Cons of Virtual Page View Tracking in Google Analytics

by MoreVisibility

Last week, we dug into the pros and cons of event tracking with Google Analytics, which sets us up nicely to discuss the pros and cons of virtual page view tracking. With the combination of this week’s and last week’s blog posts, you should have enough information to make a decision on whether to go with event tracking or virtual page view tracking for an outbound link, a PDF file, an application, a video, or something else that you wish to track on your web site.

The philosophy behind setting something up as a virtual page view is to track something as a page view that currently cannot be tracked as such. The best example I can use to elaborate would be wanting to track something that your web site offers as a file download – Microsoft Word documents, Adobe PDF files, podcasts, and the like. You could use event tracking to track these file download interactions as events, but you could also use a virtual page view to track their downloads as page views, just like any other web page on your site.

For PDF and Microsoft Word types of files, you can use a JavaScript onClick event. However, another common situation in which you’d want to use a virtual page view is one where you have to edit the Google Analytics tracking code snippet itself. This happens a lot on web forms, where the page that the form lives on (example: /contact-us.php) is the same “page” that the subsequent confirmation page lives on. I put “page” in quotation marks because developers know it’s not the same page, but because Google Analytics can’t tell the difference between pages if the URL in the browser’s address bar is the same, you won’t see any views of that confirmation page in your reports. Therefore, you will have to use a virtual page view (e.g. use the _trackPageview function) on the confirmation page to tell Google Analytics that it’s recording data for a different page than the form page.

What else do you need to know about virtual page views? Check out the following list of pros and cons and compare it to last week’s blog post on event tracking, and you be the judge.

Virtual Page View Pros:

– Any item that is tracked using a virtual page view can be set up as a goal in Google Analytics. That’s because Google Analytics treats virtual page views and actual page views the same way (it considers them both as pages on your site). Therefore, you can set up your PDF file downloads as a goal, for example.

– You can differentiate pages that use the same URL in the browser’s address bar in your reports. This is great for any situation where the URL in the browser’s address bar does not change, like in the example above on web forms. This sometimes is also the case on a shopping cart checkout process – multiple pages using the same URL, making a great excuse for you to implement some virtual page views.

– All of the nice web analytics metrics that you have come to know and love are also collected and reported on when a visitor interacts with something set up with a virtual page view. Bounce rate, average time on page, and even the $Index metric are all available.

Virtual Page View Cons:

– Any virtual page view, if used by a visitor, will inflate your page view count in reports, along with other metrics. If, for example, you set up a virtual page view on an outbound link that leaves your web site, that action can increase your time on site and page view metrics artificially, which may be a burden to you.

– If you have lots of files and lots of actions to track as virtual page views, this could mean a sizable work-load for someone in your IT or web site development department. Unlike installing the standard Google Analytics tracking code, installing virtual page views is a manual process, and possibly, a costly one.

– All of the virtual page view data is mixed in with all of the actual / regular page view data in your content reports. You will have to make frequent use of the report’s filter tools, or possibly create an advanced segment or separate filtered profile to be able to view your virtual page view data.

Hope you enjoyed this two-part series! Let us know if you have any questions or comments – or your own pros and cons of using virtual page view tracking!

August 5 2009

Tracking PDF Downloads in Google Analytics

by MoreVisibility

PDF Files are no doubt a part of your website. Sure, they’re not HTML, PHP, or ASP pages, but they are files that contain information that is just as valuable as any other page on your website. So, why not track PDF files in Google Analytics, too?

At MoreVisibility, we see a lot of websites out there using Google Analytics that are not tracking their PDF Files as either pageviews or events – both of which are possible to do. The best part about it is that it’s very easy to configure, which is good news for any person on your IT / technical team.

To track any PDF file on your website, simply follow the quick steps below and you’ll be well on your way. It gets a bit technical from here on out, so roll up your sleeves and put your hard hats on.

1. Find a page that links to one of your PDF files.

2. Find where the PDF file is on the page – look for the anchor (<a>) tag. It should look something like this:

<a href="files/quarterly-earnings.pdf" target="_blank">Quarterly Earnings Report</a>

3. Insert the following “onClick” event within this anchor tag. It should look like this:

<a href="files/quarterly-earnings.pdf" target="_blank" onClick="pageTracker._trackPageview('/files/quarterly-earnings.pdf');">Quarterly Earnings Report</a>

4. Upload the page and enjoy the results! You should see the number of times that your PDF file was accessed within the Content >> Top Content section of your Google Analytics profile.

Tracking a PDF Download as an Event (vs. as a Pageview)
To track your PDF Downloads as Events, simply use the _trackEvent function instead of the _trackPageview function, like so:

<a href="files/quarterly-earnings.pdf" target="_blank" onClick="pageTracker._trackEvent("PDF Files", "Downloads", "Quarterly Earnings Report", "500");">Quarterly Earnings Report</a>

(Learn all about Event Tracking with my latest blog post from last week)

The activity that occurred on your PDF Files will be within the Event Tracking section, which is a sub-section of the Content section of reports, instead of in the Top Content report.

Is there a difference between tracking PDF files as Pageviews or as Events?
Other than the obvious fact that one way will count them as a pageview, while the other way will count them as an event, the biggest difference between the two is the ability to track Goals. As of today, Google Analytics does not have the ability to track Events as Goals, so if you were planning to track all PDF downloads as Goals, you will need to track them as Pageviews, and not as Events. Advanced Segments are now available for Events, but they are not the same as Goals.

So what are you waiting for? Grab your webmaster and start tracking your PDF files with Google Analytics!

© 2021 MoreVisibility. All rights reserved.