views:

542

answers:

3

I would normally use Google analytics because it is free and simple to implement but on this occasion we need an internally built reporting system. This system needs to be in .NET only because JavaScript is not an option.

My question is how do you track unique visitors when you can never be sure that they have cookies turned on?

I was going to track them by setting a cookie with a GUID, then store this ID in the database against every page hit. The problem is that if they don't have cookie's enabled it is impossible to know if you are creating new cookie's every time they hit a page because the last cookie wasn't actually accepted due to them being disabled. You obviously can't use sessions to track it because they are in exactly the same boat.

I imagine some of you are going to say to create a couple pages that check for cookies before the user enters the website, but that won't help because the users won't always come in from one point on the website.

Google must manage to do it, albeit they use JavaScript.

The reason why creating a new tracking ID is a problem is because it will throw my reporting out of whack compared to what it should be. Let's say I have 4 user's visit and each of them visits 10 pages. If one user doesn't have cookie's enabled it will say the website has had 13 unique visitors.

A: 

I'll advice you to track users in your db thru server side code when they/users use your first page say when they login page:

with the help of this :HttpBrowserCapabilities browser = Request.Browser; you will get the information like which browser is being used, cookies are set or not etc... then depending on cookies are set or not you can manipulate the things / track required info you need.

Samiksha
You can only find out if cookies are available through the browser not if they are actually enabled or not.
John_
+1  A: 

Firstly, unique users is always an approximation. There is no guaranteed way to force cookies, their persistance is not completely in your control anyway, and IPs often represent blocks (sometimes vast) of users. Data quality is not good in this area, you just have to accept that.

This is a good primer on cookie analytics.

In my experience tracking IPs does at least offer a safe lower bound, but you're still talking about vague data.

All other cookie alternatives I'm aware of are transient only.

Secondly, what do you mean by "JavaScript is not an option"? ASP.NET functionality is (imho) severely curtailed by turning JS off, and your options will be more limited. Is that the state you're expecting?

annakata
I don't want to use javascipt because to manage that is trickier when changes are made to any code. If it is done server side it is easier for people to add code into a generic base Page class which can then be run on every page easily.
John_
That's a pretty flawed argument. It would be just as easy to put a reference to a javascript file in a master page.
annakata
A: 

First off, you'll never get 100% accuracy. Period. Having said that, there's a few things you can do.

I started typing up how you could build a cookie-less tracking mechanism, and when I was half way, I thought to myself "self, surely ASP.NET would support something like this out of the box?". And indeed: Cookieless Session IDs. This would at least allow you to determine which requests were coming from a particular (though still anonymous) user within a single session.

Not sure if you can mix this with using cookies if they're available (which would result in nicer URLs, and possibly give you the opportunity to track users across sessions), but it might be a start.

Arnout