Geeky Google Analytics

Google Analytics is awesome, there is no doubt about it. It’s easy to integrate into websites and the UI to get metrics information out of is pretty cool too, especially the real time stuff which now seems to work better than ever. However, when I’m asked particularly complex metrics-based questions by guys I develop sites for I often find it difficult to get exactly the information I need from the standard Google Analytics UI.

Instead, I find the Google Analytics Query Explorer 2 tool useful. It’s not pretty, but it allows me to build up complex analytics queries in a single screen without having to search around for filters and options. It feels more like writing SQL against Google’s Analytics store rather than battling with the standard UI they wrap around the numbers. I wouldn’t be surprised if the default UI uses the Query Explorer behind the scenes to get at the numbers either.

Enjoy!

WordPress and Google Analytics

Following on from my last post in which I describe how to include code snippets in WordPress posts, I also decided it would also be great to track visitors to my blog using Google Analytics. Fortunately, this was very easy to set up.

The first step is to create a Google Analytics account. This is easy and fully explained by Google so I won’t go into details here. Once you have created your account you should be able to see your tracking code, which for me looks like this:

<script type="text/javascript">// <![CDATA[

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-39305296-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

// ]]></script>

To monitor your WordPress site using Google Analytics you simply need to open the editor under the ‘Appearance’ menu, select Footer (footer.php) and paste the entire tracking code block just before the closing body tag:

</body>

Once done, Google Analytics will monitor traffic to your site.

Addendum: Warning! Updating your WordPress theme will overwrite any customisations you have made to the files. So, if you run a WordPress auto-update, be prepared to have to re-paste the Google Analytics code in again.