Friday, February 6, 2009

Getting Some Serious Analytics

I decided tonight to wire up my personal and professional blogs with google analytics. Using it I hope to learn more about what types of posts readers are most interested in so that I can write more along those lines.

Actually, we already use google analytics for our work blogs at Atalasoft. Our whole site is wired up with it. However, the analytics information is only really used for measuring the evaluation funnel by our marketing department. While I could probably see the data if I wanted to, I doubt I'd be able to set up custom goals and such. This is why I added my own additional calls to analytics.

The most difficult part was wiring things up to do tracking of miscellaneous links and buttons. I had to look up each button/link id in firebug and write some javascript to do the onclick assignments. This is the code I ended up using on my work blog:


function SetYourGoals()
{
if (typeof(_gat) != "object") { return false; }
if (!document.getElementById) { return false; }


var googlePageTracker = _gat._getTracker("??-???????-?");
googlePageTracker._trackPageview();

var myGoogleGoals = new Array();
myGoogleGoals['bp___v___bt___s___rss'] = "/goal/feed";
myGoogleGoals['bp___v___bt___s___atom'] = "/goal/feed";
myGoogleGoals['bp___v___bt___s___email'] = "/goal/feed";
myGoogleGoals['bp___v___bs___lcl___Categories_ctl02_Links_ctl01_Link'] = "/goal/personalmisc";
myGoogleGoals['bp___v___bs___lcl___Categories_ctl02_Links_ctl02_Link'] = "/goal/personalmisc";
myGoogleGoals['bp___v___bs___lcl___Categories_ctl02_Links_ctl03_Link'] = "/goal/personalblog";

for (var i in myGoogleGoals)
{
var ahref = document.getElementById(i);
ahref.onclick = function()
{
try
{
googlePageTracker._trackPageview(myGoogleGoals[i]);
}
catch (err)
{
}
return false;
}
}
}

function AsyncSetYourGoals()
{
window.setTimeout(SetYourGoals, 5000);
return false;
}


Anyone get the CIV reference?

No comments: