There is a lot of confusion with Virtual Pageviews and Events in analytics. Google recommends Virtual Pageviews to “track clicks from users that do not lead to actual website pages on your site”. Even though the user click does not result in a change to the URL, the website owner views this action as equivalent to generating a new page and therefore will want to implement Virtual Pageviews. Event Tracking is different than Virtual Pageviews and is best used for downloads, outbound links, and other similar user interactions. In this article, you’ll learn when and how to use Virtual Pageviews in your Google Analytics account.
A Virtual Pageview reports data in analytics like any other “real” page on a site. In other words, data about Virtual Pageview activity is viewable along with the built-in data about standard pageviews. Since Virtual Pageviews are treated like regular pages, they will also increase the pageview count. Since this is an artificial inflation, users of Virtual Pageviews need to make sure they view these as equivalent to a regular pageview so they do not end up with messy data. Adding Virtual Pageviews is telling Google Analytics to see a page when the page URL did not change. If this action is really similar to the experience of a new page, then it is a good idea to implement Virtual Pageviews.
If there is a concern about the inflated page count, one way to manage that is to add a prefix such as “virtual/” before the Virtual Pageview URLs. The number is still inflated overall, but users can easily recognize Virtual Pageviews in reports by looking for this prefix. Another option is to create a new view in the Google Analytics account just to track Virtual Pageviews. This method is not one I recommend because users are then going back and forth between views and it seems to defeat the purpose of analyzing all the data together. The third option is to use an Advanced Segment to view only Virtual Pageview data in the existing view. It temporarily acts as a filter to allow viewing of a specific set of data. Once the segment is removed, all the original data is still there so segments are a helpful tool to analyze different pieces of data on-the-fly.
Following are a few cases when Virtual Pageviews may be a good strategy:
- A website has a one-page checkout process, meaning the URL does not change after visitors make a purchase. In that case, it may be helpful to see this whole process in order to better understand shopping cart abandonment. A Virtual Pageview will make it possible to view the whole shopping path in one report.
- Heavy content sites where “time on page” is a crucial metric. If it is important to know how much time a user spent reading content and there are dynamic pages on the site, a Virtual Pageview will force analytics to identify each change in category content. Event Tracking will only show that the user interacted with a piece of content, not for how long.
- Any time the site owner wants to track the steps in a goal funnel and these are not built-in as regular pageviews, Virtual Pageviews need to be implemented to “create” pages that can be used in the funnel. Event Tracking occurs in totally separate reports so this method cannot be used as a metric in analyzing steps towards a larger goal. This is probably the biggest advantage of using a Virtual Pageview instead of Event Tracking.
Unfortunately, Virtual Pageviews are not a built-in feature in Google Analytics. The standard UA analytics code is easy to drop in for most websites so many people are able to install analytics without any coding knowledge. Implementing Virtual Pageviews does require some additional code, using the _trackPageview() function to create a page name for whatever it is the site owner wants to track.
Implementing this varies for Universal and Classic tracking. An easy way to identify which version is being used is to look at the source code for a site. In the code near the UA number, it will have “ga.js” for Classic tracking and “analytics.js” for Universal tracking.
Installation of the Virtual Pageview code varies slightly. With Universal Analytics, the code will include something like ga(‘send’, ‘pageview’, ‘page’);. Those who are still on Classic Analytics will have slightly different code with _gaq.push([‘_trackPageview’, ‘page’);. For site owners who are not the ones implementing code, that information is enough to know – simply that there is a slight difference for Virtual Pageview tracking depending on the type of analytics code. Developers can refer to Google’s guide for specific detail about implementation.