Case Study: Geolocation and Automatic Currency Detection

Globe
Photo credit: Kevin M Gill

Our client has a thriving e-commerce site which we built a few years ago. They sell all over the world and accept payments in a number of different currencies. The challenge with this project was to ensure that customers outside the UK were presented with prices displayed in their home currency.

For this we implemented a geolocation lookup using the reliable ip2location service. This takes the user’s IP address and performs a lookup against ip2location’s database, returning the country the customer is in with extremely high levels of accuracy. The service is fast enough to be done on-the-fly without any noticeable slow-down in accessing the site.

Performance – speed is king

Geolocation

The process of identifying the geographical location of a person or device by means of digital information processed via the Internet

Performance in any web application is key, so instead of performing the lookup every time a visitor arrives at the site, we cache the lookups in the database. We first perform a check against the database to find out if we have already done a lookup on the IP address within the last few days. If so, we don’t need to call ip2location for the country, and we retrieve it from the database. This makes things even faster.

Testing

One of the challenges of web development is finding out what your site/pages look like in countries outside the UK. To do this we employed several techniques. We tested using many web proxy services, and also utilised a great service called GeoPeeker to get a view from the USA, Brazil, Singapore, Ireland and several other locations.

Success

Now the service has been launched, so customers around the world are presented with their “home” currency. This is great customer service and is a handy time-saver for customers who no longer have to change their currency from UK pounds to their home currency.