Tracking User Interactions

Saturday, February 25, 2006, at 07:06AM

By Eric Richardson

One of the more interesting things (to me at least) that I did in the process of launching the new map application was add tracker calls in the database to reflect usage that normally wouldn't get reflected in the stats. I'm using Google Analytics for this, and I hadn't realized just how easy it was.

In the map application it's important for us to know about user interactions. How are people using the map? Are they doing searches? Are they clicking the map links to find buildings on the map? Are they clicking on the map to find info about buildings?

Some of these interactions occur entirely in client-space as communication between the Javascript and Flash. Using analytics, though, it was easy to add tracking on them. For instance, here's my JS code to load buildings details:

showDetails : function (id,from) {
    Element.update(
        'results_detail',
        '<img src="/images/spinner.gif" '+
        'height="16" width="16" alt="" '+
        'align="left"/><p>Loading...</p>'
    )
    this.setResultMode('detail');
    new Ajax.Updater(
        'results_detail', 
        '/dtla/details?map_key='+id,
        {asynchronous:true, evalScripts:false}
    );

    var log = (from) 
        ? '/Details/' + from + '/' + id
        : '/Details/unk/' + id;

    urchinTracker(log);
},

To log where the user is generating the details call I add that from var. So a call from the map would be dtla.showDetails('405','map'); and would generate a hit to /Details/map/405 in my analytics logs.

Now if only analytics didn't have such a delay in stats showing up. For new sites, or cases where you've made new changes, it's rough to have to wait 24-hours to see the results.