call +44 (0)1273 622272
Virtual PageViews in Google Analytics
In our last free Google Analytics resource we looked at how to set up Goals in Google Analytics. Some of those goals required virtual page views to enable you to track user clicks on things that don’t have a URL within the site that can be tracked in the usual way (e.g PDF downloads).
So – we thought it only fair to let you know how to set up Virtual Page views too!
Check out our step by step guide below. To learn about all of this in more depth and try it out hands on – why not come along to our next Google Analytics Training course here in Brighton?
Virtual page views can be used to track clicks on any links that do not lead to a standard URL within your site. That includes:
Virtual page views will only work if you’ve got the most recent version of the Google Analytics tracking code (known as the async code) installed on your site, so first step is to make sure you’ve got it.
A quick way to check this is to visit a page on your site – right click somewhere on the page and select view page source (or whatever the equivalent is in your browser), and search for the phrase async in the code. If you find the line that includes ga.async = true; then you’re already in business – ignore the next bit!
If you can’t find that – you’re using the old code and you’ll need to update it.
Log in to your Google Analytics account.
Hit the Edit button to the right of the profile you’re using
Now (and this is a silly place to put it) look in the top right hand corner of the profile settings page where it says “check status”
![]()
Click on this and the tracking script for your account is there to copy and paste. If you’re not sure where to paste it, check out our post on how to install the Google Analytics Tracking Code
If you know a little bit of HTML, this is pretty straightforward. You just need to add a little bit of code within the <a> tag for the link or button that you are tracking the clicks on.
That code is:
onClick=_gaq.push ([‘_trackPageView’,’/YOUR-CHOICE-OF-PAGE-VIEW-NAME-HERE’]);
So – if you want to track the number of people who are downloading a PDF, you might call your virtual page view “PRODUCTx-PDF-DOWNLOAD”
To show exactly where you should put the code – see the before and after code for the “Download PDF” button for our Google Analytics Course PDF below.
Without Virtual Page View Code
<a href=”http://www.siliconbeachtraining.co.uk/downloads/courses/advanced-google-analytics-training-394.pdf” title=”Download Google Analytics Training course outline” target=”_blank”>Download PDF</a>
With Virtual Page View Code (in bold)
<a href=”http://www.siliconbeachtraining.co.uk/downloads/courses/advanced-google-analytics-training-394.pdf” title=”Download Google Analytics Training course outline” target=”_blank” onclick=”_gaq.push(['_trackPageview','/google-analytics-PDF-Download']);”>Download PDF</a>
With the above code in place, we’re now able to start tracking how many people are clicking on the PDF download for our Google Analtytics course (and all of our other PDFs, which we’ve also applied this method to), which we wouldn’t be able to do without virtual page views. Hurrah!
Once you’ve implemented the code – your virtual page views will start showing up in your Google Analytics content report just like your ‘normal’ page views.
Simply go to your top content report and filter the results by the name of the virtual page (or pages) – and hey presto – tracking for things where tracking was not possible before:
![]()
Related posts:
Related posts:
advanced google analytics training, google analytics, Google Analytics Training, how to set up virtual page view, how to track external links, how to track form submissions, how to track PDF downloads, setting up virtual pageview google analytics, virtual page view, virtual pageview, what are virtual page views, why use virtual pageviews
Silicon Beach Training