I’ve recently been looking at how I can use Google Analytics to track website usage of content based on the category it has been assigned. We are using META tags in the page headings to store the category name and title of the content.
Google have just rolled out a bunch of excessively handy features allowing custom variables in their most recent update to the analytics package, unfortunetly my Analytics account hasn’t yet been updated to include them. As a fall back I’ve used the Event Tracking functionality instead.
At the bottom of each page which I want to track the category of, added the following code;
-
-
<script type="text/javascript">
-
var pageTracker = _gat._getTracker("<%= googleAnalyticsId %>");
-
-
function getMeta(name) {
-
var metas = document.getElementsByTagName(‘META’);
-
for (var i = 0; i < metas.length; i++){
-
if (metas[i].getAttribute(‘NAME’) == name){
-
return metas[i].getAttribute(‘CONTENT’);
-
}
-
}
-
return "null";
-
}
-
-
try {
-
var cat = getMeta("CATEGORY");
-
var title = getMeta("ARTICLE_NAME");
-
-
if(cat != "null" && title != "null"){
-
pageTracker._trackEvent(‘Category’,cat,title);
-
}
-
}catch(ex){
-
/* do nothing */
-
}
-
pageTracker._trackPageview();
-
</script>
-
Using this codes means that I can put these meta tags into the headings of any page;
-
-
<meta name="CATEGORY" content="Analytics" />
-
<meta name="ARTICLE_NAME" content="Custom Variables" />
-
And Google Analytics will track the my each of my articles based on the category they have been tagged with.








Just upgraded to the latest version of WordPress. Each release seems to come on leaps and bounds. The new admin interface is fantastic, usable and feature rich.
Sites like Wikipedia have had a meteoric rise to fame (and potential fortune) over the last few years. There was a time when a random question was answered with a plain “I have no idea” now it’s generally a question of who can type in 







