Sometimes, the urls (and titles) of your pages are not conducive to web analytics reporting. For example, your ecommerce site’s payment, shipping, and order confirmation page may all have the same url for some reason – . To web analytics, all these funnel pages are reported as one page. You are now stuck, you can’t create ecommerce funnels and measuring shopping cart funnel abandonment is impossible. And there is a more subtle and serious issue as well, in your report, you may find hits (events, ecommerce, social, etc) associated with this url, but you won’t know what part of the order process these hits belong to.
Here’s the actual flow we want to track and understand:
If you have a shipping calculator on your shipping page, a card type drop-down on the payment page, social buttons on all pages, you want to track each of these events on each page. However, it will show like this:
All the urls are the same! How do you know if these events happened on the shipping page, payment page or order confirmation page? You might be able to tell from the event names, but in some cases you may not be 100% sure, and this is definitely not clean and ideal.
While fixing the actual real urls and title tags (assigning unique urls and titles per page) would make things very organized, your content management system may not support this, or you might prefer not to spend that time or money on developers.
Luckily, there is a secret, undocumented method that allows you to actually set the page url and title of a visited page in Google Analytics. More importantly, it will actually associate the hits with these new, more meaningful page urls and titles. Your reports will be easier to read and will provide insights that may not have been available before.
The Issue With Virtual Pages
The traditional solution to this would be to use the _trackPageview method and trigger virtual pages for each “step” (i.e. /virtual-page/shipping.html, etc.).
_gaq.push(['_trackPageview', '/new-meaningful-url.html']);
The drawback here though is still, the actual events will not be associated with these virtual pages you’ve created. They will always be connected to the “real” page, which would be /checkout.aspx (as you can see in the screenshot above). You’re still lacking potentially valuable insights.
SECRET HACK! Setting the URL and TITLE in Google Analytics – _set method
With this new _set method, you can manually set the url and title of the page to whatever convenient name you want.
<b><i> _gaq.push(['_set', 'page', '/new-meaningful-url.html']);</i></b> <b><i> _gaq.push(['_set', 'title', '</i></b><b>New Meaningful Title']);</b>
Simply push the new page’s title using _set method before calling your _trackPageview…
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']); _gaq.push(['_setDomainName', 'e-nor.com']); <b><i> _gaq.push(['_set', 'page', '/new-meaningful-url.html']);</i></b> <b><i> _gaq.push(['_set', 'title', '</i></b><b>New Meaningful Title'</b><b><i>]);</i></b> _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'https://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>
In the case of the ecommerce example mentioned earlier, for each page you’d like to rename, you can pass the preferred url and title so that it’s separated and meaningful in Google Analytics and associated WITH THE HITS:
<i>_gaq.push(['_set', 'page', '/shipping.html']); _gaq.push(['_set', 'title', 'shipping page']);</i>
OR
<i>_gaq.push(['_set', 'page', '/payment.html']); _gaq.push(['_set', 'title', 'payment page']);</i>
OR
<i>_gaq.push(['_set', 'page', '/confirmation.html']); _gaq.push(['_set', 'title', 'order confirmation page']);</i>
You’ll be able to see events and figure out things like “Did they abandon the cart at the payment page? At the shipping page? What are they clicking on the order confirmation page?” etc.
What do you think? Share what other use cases you might have in mind.