Tracking anonymous users on your website

Posted on Posted in Technology Center

One of our project requirement is to be able to track individual users, including guests. Tracking guest/anonymous users can be quite challenging considering the different possible scenarios.

The easiest scenario is when the browser supports cookies, in such case, just assign a unique ID as a cookie and retrieve the cookie everytime access is made. The basic concept is to create an ID that will not likely be duplicated in any user. So, in our case, we used IP Address + User Agent + Forwarded For + Time + Random number. That should create unique ID for anybody accessing the site anywhere and anytime in the world.

The second scenario is when the browser doesn’t support cookies. This is more involved because we need to assign an ID unique and consistent for a specific user. In this case, we used IP Address + User Agent + Forwarded For. There are some pitfalls with this approach, such as when user changes internet connection on a DHCP network… but I guess that’s a bit of a technical limitation at the moment.

In any case, below is the code snippet used to create the unique ID key, the solution below is a combination of PHP and Javascript codes:


3 thoughts on “Tracking anonymous users on your website

  1. Hey dudes,
    I just wanna point out, that this: is in the js alert. I guess the js code is not in a php file. Try echoing it out on a DOM element with a data attribute, then get that with alert() after the document is ready.
    Cheers!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.