TAGS :Viewed: 8 - Published at: a few seconds ago

[ How to log and analyze certain user actions on my website ]

I have a simple page that provides a search experience. It allows users to search via a query form, filter results, and perform more in-depth searches based on the results of the first search.

I would like to get some metrics around the user experience and how they are using the page. Most of the user actions translate in a new query string. For example:

  • how many users perform a search and then follow up with another search / filter
  • how many times a wildcard is used in the search query
  • how many results does a user browse before a new search

I am also limited of using google analytics and the sort because of copyright issues (maybe I can make a case if it is really the way to go for open web analytics or smth). Server side I am thinking of using cookies to track users and log4net to log what they do, then dump the info in a db and do analysis from there. Or log to the event viewer and use the Log Viewer to get the info from there.

What do you think is the overall better approach?

Answer 1


I would recommend you use an existing, off-the-shelf solution for this, rather than building your own - it's the kind of project that very rapidly grows in size. You go from the 3 metrics in your question to "oh, and can you break that down by the country from which the user browses?", "what languages affect the questions?", "do they end up buying anything if they click results for bananas?". And then, before you know it, you've built your own web analytics tool...

So, you can either use "web analytics as service" offerings like Google Analytics, or use a more old-fashioned log-parsing solution. Most of the questions you want to answer can be derived from the data in the IIS web logs; there are numerous applications to parse that data, including open source and free solutions.

It's been a long while since I used a log file based analytics tool, but my ISP provides AWStats, which seems pretty good - to do what you want, you'll have to set up specific measurements around your search page; not sure if AWStats does that (Google Analytics definitely does); check the Wikipedia list for log file analysis tools which do that.

Answer 2


Obviously you need to log every submit of the search page. In particular you need to log:

  • DateTime.Now
  • SearchString
  • SessionID

You could also store a counter in the Session that will be incremeted each time a user loads a page, that is not the search page. If the users performs a search you could read that value from the session, store it in the database and reset the counter.

Be aware that the metric of "how many results does a user browsw before a new search" should only be taken as an estimate and not as a real metric, due to cookie support, multitabbing, page reloads et cetera.