Search code examples
javascriptuniquehit

Identifying unique hits with JavaScript


Could you suggest an efficient way to identify a unique user with JavaScript (e.g. calculate a hash to send to the server-side)?

EDIT: The point is that I can't "intrude" into the browser (e.g. send cookies). And IPs are also not the option. And it has to be a client-side solution (therefore JavaScript).


Solution

  • A common solution to this problem is to calculate a unique ID on the server side, then push a cookie to the browser containing that ID (checking, first, to see whether that cookie has already been defined for the current browser).

    Advertising networks use that technique fairly heavily to gather demographic information on web users.

    EDIT By the way, the "unique ID" can simply be the first session ID associated with the user. Many frameworks can supply that for you.