facebook google plus twitter
Webucator's Free Advanced Google Analytics Tutorial

Lesson: Virtual Pageviews

Welcome to our free Advanced Google Analytics tutorial. This tutorial is based on Webucator's Advanced Google Analytics course.

In this lesson, you will learn the basics of virtual pageviews, and how you can apply them to your reporting capabilities.

Lesson Goals

  • Fundamentals of Virtual Pageview.
  • How to create a Virtual Pageview.
  • Application of Virtual Pageview.

Introduction to Virtual Pageview

By default, Google Analytics tracks viewed pages by calling the JavaScript method called _trackPageview () in the GATC. Google Analytics records the URI directly from your web browser and displays it in the report as the pageview.

However, you are allowed to override this normal function by modifying the _trackPageview method to create virtual pageviews. For example:

gaq.push(['_trackPageview','pass any alpha numeric value']);

gaq.push(['_trackPageview', '/courses/ILO/Web Analytics/GoogleAnalytics101']);

In the first example, the parentheses contains a pseudo page name i.e. 'my first virtual page view' and in the second example the parentheses contains a pseudo directory structure.

Why to Use Virtual Pageviews

Virtual pageviews are extremely helpful in the following situations:

  1. Your website has a complex URL structure due to dynamically generated web pages.
  2. You want to track file downloads.
  3. You want to track outbound links.

Virtual Pageviews and Dynamic URLs

If you have a website that dynamically generates pages based on certain query parameters then you can use virtual pageviews to help clean up your Content Report. Virtual pageviews will help make your reports easier to read and understand.

For example, if your original link looks like the following example, then it will be difficult to interpret the same in your Google Analytics reports.

http://www.example.com/s/ref=amb_link_85318851_3?ie=UTF8&node=565108&field-availability=-1&brand=acer&emi=ATVPDKIKX0DER&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-5&pf_rd_r=0YMSR93FFWM4QZ1Y9ZVF&pf_rd_t=101&pf_rd_p=1243829422&pf_rd_i=565108

To resolve this, add the following line of code in addition to the GATC:

gaq.push(['_trackPageview','/products/electronics/computers/netbooks/accer']);

By doing so you will generate a virtual pageview with a meaningful name, and thus you can categorize all such dynamic pages into groups within your contentreport.

Virtual Pageviews for Tracking File Downloads

Google Analytics by default cannot track any file downloads by using standard GATC implementations, since a file download will not trigger a new pageview. Thus, you will need to create a virtual pageview to trick the system to generate a pseudo pageview when someone downloads a file from your website.

For example, if your original link looks like:

<a href="http://www.example.com/GPriceList.pdf">Download a PDF</a>

You need to modify the above link to look like:

<a href="http://www.example.com/report.pdf" onclick="_gaq.push(['_trackPageview', '/vp/downloads/pdf/GlobalPriceList.pdf']);" />Download a PDF</a>

By doing so, you will generate a virtual pageview when someone clicks on the download link. Virtual pageviews are captured in the Top Content and Content Drill Down reports.

Virtual Pageviews and Tracking Outbound Links

Google Analytics by default cannot track your outbound links. However, you can leverage virtual pageviews to track any outbound links which you may have on your website.

For example, if your outbound link looks like:

<a href="http://checkout.google.com">Click Here For Shopping Cart</a>

You need to modify the above link to look like:

< a href="http://checkout.google.com" onClick= "_gaq.push(['_trackPageview', '/outbound/checkoutprocess/checkout.google.com']);/>Click For Shopping Cart</a>

By doing so, you will generate a virtual pageview when someone clicks on this outbound link. The virtual directory structure will provide context for your report analysis.

Application of Virtual Pageviews in Goals and Funnels

Duration: 10 to 15 minutes.

You would like to track a pdf file download as a goal in Google Analytics. Accomplish this task using virtual pageviews.

Solution:

1. Modify your original download link with the _trackPageview method. For example:

<a href="http://www.example.com/report.pdf" onClick= "pageTracker._trackPageview ('/Reports/Nasa.pdf');">Download a PDF</a>

2. Within an appropriate profile create a new Goal.

3. Use the following configuration for your new Goal. Note that the Goal URL in the following screen shot matches the virtual pageview that you created in step 1.

Adv Segment Default