Accessibility Navigation

ImageXY

ImageXY - Mac OS X Batch Photo Resizer

Checkout ImageXY - Painless image resizing for Mac OS X.

Quickly and painlessly bulk resize images, change image formats and create web-friendly photos for your website.

Available on the Mac App Store!

Asynchronous Virtual Pageviews with Google Analytics

If you have moved over to the new Asynchronous Google Analytics (GA) tracking code you may have trouble finding how to create virtual pageviews as the manual seems to push you more towards using Events instead.

How do I tell if I’m using the new code?

Google provides a good step by step guide to work out which tracking code you’re using. The gist of it comes down to looking for the following piece of code in your <head> section:

var _gaq = _gaq || [];

If you see that piece of code, or any reference to ‘_gaq‘, then you’re using the newer asynchronous code.

New Asynchronous Virtual Pageview Code

Now that you know you’re using the newer asynchronous code, you will need to use the following snippet in your links to track virtual pageviews.

<a href="" onClick="javascript: _gaq.push(['_trackPageview', '/virtual-page']);">My Link</a>

If you’re not a fan of embedding JavaScript directly into the page (for graceful degradation) then you can call the same method within your external function:

function trackVirtualPageview(strPage){
    _gaq.push(['_trackPageview', strPage]);
}

About The Author

Jacob Wyke is a web developer from the UK who makes complex things simple on the internet. He develops a batch image resizer for Mac OS X called ImageXY which you should try if you ever need to resize anything for the web.

You should also follow him on twitter.