1 min.
Virtual pageviews in Google Analytics
1L’art de la gestion de projet2Un projet à succès commence par une bonne gouvernance3Cascade, agilité, demandes de changement?

Virtual pageviews in Google Analytics

Analytics & Tracking

It happens that for a technical reason, two pages of our site have the same URL. This is often the case for an order taking process or for a confirmation page. In this case, how to distinguish them in Google Analytics? How to create a navigation path for a checkout process if the URL of the billing page is the same as that of the shipping page?


A first solution consists in changing the URL of these pages. If it were so simple, this post wouldn't be relevant… To avoid a fight with the IT team responsible for the site, opt instead for the solution of virtual page views.


Let's analyze the Google Analytics tracking code (GATC – Google Analytics Tracker Code ) to understand what a virtual page view is: 

<script type="text/javascript"> 
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." :
"http://www."); document.write(unescape("%3Cscript src='" + gaJsHost +
"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3639329-3");

The line that interests us here is the one that registers a page view in Google Analytics. It is the _trackPageView function which is responsible for this work. Each time this function is called, Google Analytics records a page view. By default, the function retrieves the URL as it appears in the browser's address bar and saves it.  

By specifying a parameter to the _trackPageView function , GA records a page view by replacing the page URL with the parameter value. In short, it generates a virtual pageview .  


Let's take the example of the checkout process on an e-commerce site as follows, with corresponding URL:

To distinguish the Billing, Delivery and Summary stages, simply change the line that registers the page views in the GATC. For instance:

  • Billing
  • Delivery:
  • Summary:

And There you go! Now all that remains is to use these virtual URLs to configure a corresponding goal in Google Analytics and analyze the abandonment rate at each of the stages…