If you use Google Analytics, you know it tracks visitors to your website, the number of pages they viewed, bounce rate and various other metrics. Using Google Analytics, you can determine most popular pages on your site, the pages by which people most commonly enter your site, and the various pages you set as goals for visitors to complete.
What Google Analytics doesn't measure is file downloads. So what happens if one of your goals is to have a visitor to your site download a file, such as a PDF?
Events are built-in to Google Analytics. Simply call your code and Google tracks it in the event.
The trackEvent code needs two pieces of information: category and action. You can also opt to give three more pieces of information: an optional label to better define your event, an optional value to quantify the event numerically, and an optional flag to define whether the event will be used in bounce-rate calculation.
When applied to a PDF download, it would look something like this:
< a href="myfile.pdf" onClick="gaq.trackEvent('Downloads','PDF','myfile.pdf','1.50',true)"/>
This line of code creates a hyperlink to my file.pdf and tells Google Analytics to track an event every time the link is clicked. The event will register in the downloads category. "PDF" would be the action and the label is my file.pdf. The line also sets $1.50 as the value and disallows this visitor action from triggering a bounce.
Using Virtual Pageviews
Virtual pageviews use the same trackPageview call already installed on your website. By default, that pageview tracker tracks the current URL in the browser. However, if an optional URL is passed to the trackPageview call, it will track that URL instead of the current page. When used in the PDF download example, it looks similar to this:
< a href="myfile.pdf" onClick="gaq.trackPageview('/myfile.pdf')">
Like before, this line of code tracks the my file.pdf download when the link is clicked. This time, however, the download will be tracked in the Content section of Google Analytics. Since you're tracking a pageview, this automatically will count as an additional page, thereby never registering a bounce.
What's the Difference?
Does it matter? Each has their own merits. Goals can be measured as pages or events. Both have funnels or flows to follow a visitor's path through your site.
Strictly speaking, a file download isn't a page to be viewed. So marking a pageview might not be the most precise solution.
Justin Cutroni, Analytics Advocate at Google, literally wrote the book on Google Analytics. I reached out to him recently, asking which method he preferred:
Thom Craver: Which do you prefer for tracking non-HTML file downloads - virtual pageviews or events?
Justin Cutroni: I like to use events. As long as your tool support events. I don't think that non-HTML files [are] pages, so events make more sense to me.
TC: Fundamentally is there a practical difference where you would choose to use events over virtual pageviews?
JC: There are almost no differences between an event and pageview. Both are used in time calculation. Both can be configured as a conversion. The only slight difference is that a virtual pageview can be used in a Goal Funnel. However, Event Flows will show the progression through a series of events. While it's not the same as a conversion funnel, it's getting closer.
TC: Should I change what I'm using based on your answer? Or is it enough just to say I'm actually tracking and measuring?
JC: If it ain't broke, don't fix it! Reconfiguring analytics, and changing your metrics can cause a lot of headaches. While I firmly believe that your analytics needs to change as your marketing tactics and strategies change, I also believe in data consistency. At the end of the day, this isn't about right or wrong. This is about getting data. And if the data works for you, then you're OK.
Are you tracking file downloads? If so, which method do you use? Tell us in the comments below.
A very special thank you to Justin Cutroni. For more on how to implement events or virtual pageviews and other features in Google Analytics, check out Thom Craver's Introduction to Analytics session on Day 1 of SES Chicago, taking place November 12-16.
The Original Search Marketing Event is Back!
SES Denver (Oct 16) offers an intense day of learning all the critical aspects of search engine optimization (SEO) and paid search advertising (PPC). The mission of SES remains the same as it did from the start - to help you master being found on search engines. Register today!