Google Analytics Virtual Pageviews, Java Script Page View Count

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=”” 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.

Google Analytics Virtual Pageviews, Java Script Page View Count

Get more info about ecommerce wed design services and search engine optimisation

Artur Jach Written by:

Find out more

Comments are closed.