I am just exploring on what is the best practice/framework for implementing feature for collecting and displaying user activity statistics that is user specific and site relating to login user activities in ASP.NET. For example, I will want to know for a particular login user on my site, which site he/she has visited in the last day, week or etc. What is the frequency? top 5/10? and for the overall site, what are the top 5 popular pages or search terms (based only on login users not crawler or anonymous visits)
I have used web stats tool like getclicky, webstats and google analytics. They are all great but the tracking is based on generic visits but what I want is to tie it in with individual users/roles or organisation structure defined in my system and be able to report on them to the stakeholders.
This gets more interesting too if we have hierarchical structure say, user->department/group->company and try reporting on what are the top 5 sites for this user? what are the top 5 sites visited by users in this department/business units/group? what are the page frequency?
QUESTION: So what is the best way to implement this in ASP.NET? Is there a httpModule handler, framework or product that does this?
I will tell you what I have done.
- If you know what you're looking for in the statistics, eg as you say, what is the frequency then make this statistic calculation when you insert the new data.
For example let's say that you search how many pages user A have visited. Keep a line on statistics table that connect this user A, with the informations that you need to have, and you calculate them the moment you enter them, eg in every page just increase the counter of how many have see. That way you can have online statistics avoid background work, and thousands of line entries. I believe that you need to know what statistics you're looking for at the first place, and if there are some more in the future, then you add them later.
- You add the call to statistics calculation and insertion on the end of page, either with a thread or with a call to an extra handler so the user do not have delay to see the page.
eg, on the end of the page:
<img src="/myStats.ashx?infos=CodeStringWithSomeInfos">
on myStats.ashx, save your statistics data, and return an emtpy gif.
- Also when you show the data, even if you calculate most of your information on time, there are always extra things that you can not calculate, when you show this statistics and make this calculations, keep them on an extra table cache to speed up.
I'm not sure of the specifics, but I was under the impression you can add custom fields to google analytics. You could use this to record user, role, any business specific data you record about a user in the server app. If analytics does not have this option, Omniture definitely does (it works much like google analytics in that it uses javascript tracking). Omniture is not a free solution. (www.omniture.com)
Another idea (in order to get greatest control over activities of logged in users), you could use Logging framework with custom context (Commons Logging with Log4Net provider for example) and then use database appended. You would have complete control over logging as it pertains to user activities. By using database appended, calculating stats would be pretty straightforward...
I think GA is not the best solution for you.
There are a lot of other WebAnalytics solution that can give you a more flexible tracking.
I think the best free solution is Yahoo WebAnalytics. It will give you a tracking code similar to the GA one but with a lot more Custom Variable.
The Best paid solution in your case i thik is Adobe SiteCatalyst that with 150 custom variable, herarchical variable and so on is the best platform in the market.
Claudio.