Where do your users come from: detecting user location on websites

Detecting your website user’s (approximate) location has huge benefits in providing relevant experience without them telling you anything. There are a couple of techniques available today that let you do that: a) detect approximate location by IP address b) detect more accurate location using WiFi base stations (and their MAC Addresses) c) Cell tower triangulation (mobile client only) d) GPS (mobile client only). If you limit the options purely for Web Browsers and Desktops, its just IP and WiFi based location detection that’s available today.

The IP Address based detection is less accurate but hassle free (your users don’t need to install anything); implementing such a solution usually means that you license an IP to Geo database to look up parts of IP address to calculate a latitude/longitude value; which is fairly simple thing to do. Having said that, if you are using Google Maps for your website, detecting user’s location using IP address has gotten much easier: Google maps announced that the developers can now detect user’s approximate location based on their IP address at the time of loading the map. According to the documentation, the implementation looks fairly straight forward:

//Load the map.
function loadMaps() {
    google.load(“maps”, “2”, {“callback” : mapsLoaded});

//Check if the client location is available. If it is set map center.
function mapsLoaded() {

    if (google.loader.ClientLocation &&
         google.loader.ClientLocation.latitude &&
           map.setCenter(new google.maps.LatLng(google.loader.ClientLocation.latitude,
                                                             google.loader.ClientLocation.longitude), 13);

Obviously you can implement various ways to determine the zoom level based on the city/state level info – but you get the idea. In my previous job, I have developed both IP and WiFi based location detection techniques that are being used in Virtual Earth/Live Maps today – I hope to see them open up those via APIs too.

Now the other method of detecting location based on radio stations (WiFi mostly) – this usually requires some kind of installation since browsers cannot access the radio stack by themselves and they need a handshake from some kind of a plugin to scan that information and provide it back to the browsers. Skyhook is the only commercial provider that is currently providing the tools/plug-ins to use this method today. Alternatively one can obtain a crowd-sourced database full of WiFi Hotspots and their locations and write the plugin layers on top of it. Either way the depth and recency of WiFi hotspot information determines the accuracy of the location information.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s