Using Location Awareness

Please note: This post was written 7 years ago, which is an age in programming terms, so please don't treat this as gospel! I'll be updating all posts soon enough, but if you'd especially like this one to be updated let me know.

Earth

A future web design trend that I predict is location awareness, and using it to ensure a better user experience. However without access to GPS, most of the world's desktop PCs will have to rely on other means of telling servers where they are. One way that we can use today to determine the location of any given computer is by using a user's IP address and feeding it to a service that will tell us where the computer is located. Now while this sounds great in practice, in reality most services aren't all that accurate. But saying that, most can tell you what country a user is visiting from. So how can we use this is web design?

Well say for instance you have two e-commerce sites that are essentially the same shop - one for your American audience, and one for the UK. Differences might include currency conversions and product listings, and it would be nice to be directed to the right site should you accidentally visit the wrong one. For example Crucial's website alerts the user with a nice little pop-up, asking them if they would like to visit their international site, as it were, as you can see below.

Crucial Popup

This sort of interaction is really beneficial to the user because it stops them making mistakes later on, and more importantly, it's easy to accomplish!

Now instead of presenting you with all the code, I'm going to tell you how I accomplished the desired effect - hopefully I'll make you actually think about how it works 🙂

So first off I visited this code snippet page to get my code for finding out where the user is. I then took the array filled with information and used an "if" statement to evaluate it. So something like...

if($ipInfo["country"]=="GB - United Kingdom"){
  echo '<script type="text/javascript">popup();';
}

The code above will initiate a JavaScript function if the user appears to be coming from the UK. This function would do anything you want really, I would suggest you use a nice pop-up box to alert the user, much like the one shown above, and then allow them to navigate to another site. I would argue against immediate redirection, because the reliability of a free database cannot be ensured, and you wouldn't want to be redirected to the wrong site without the option to navigate back, now would you?

As I said, this is a really easy way of determining where your users are, and making a decision based on that information. Users will thank you for helping them out, and admire the fact that you know where they live!*

*Users may not be impressed by this simple technique 😉

***

If you found this particularly useful and want to share the ♥ you can donate here.

***

No Responses



~ Comments are now closed ~

Get in touch here