Not many people know about this but itâ€™s actually possible to call a page view count for any java script event.
How do I set-up Google Analytics virtual pageviews?
Well, providing that you have the standard Google Analytics setup sorted, all you need to do is add onclick=”pageTracker._trackPageview(‘/virtual-page-name’);” to the link, input, or in fact any html element capable of handling java script events.
<a href=”http://blog.pod1.com/” title=”Pod1 Blog” onclick=”pageTracker._trackPageview(‘/newsletter-signup-success’);”>Sign up to Pod1 Blog newletter</a>
How do I view results of virtual page view count?
Well, thatâ€™s even easier! Just visit Google Analyticsâ€™ content report, and search/filter for your virtual page, e.g. newsletter-signup-success. This is slightly different from the event tracking which has itâ€™s own section in Analytics
So why would I use that?
In most cases event tracking will do just fine and will do the job. However, sometimes you may want to see the stats for pages which should exist but due to design limitations donâ€™t.
For example, if the newsletter signup button doesnâ€™t take the user to confirmation page, but instead reloads the same page, there is no way of telling how many people have subscribed to the newsletter. However, when you set up virtual page views event on the button or html element presenting user with the confirmation message, the virtual pageâ€™s view count gets updated and is visible in Analytics report.