views:

330

answers:

4

Lately geo-targeting has been pretty popular in technology. By IP, cell tower, GPS, using browser plugins, HTML5?, mobile devices ...

Since I'm about to add some geo-targeted features on our site, I wanted to know what's the best approach. Is there some API that uses a mix of all those technologies? Or at least, what API/service would you recommend I use?

The service I'm working on doesn't need to be 100% accurate, so I'm OK with geo-IP, but if there's an easy way to do better, why not.

Technologies used are php, javascript, ajax, java.

A: 

GEO IP is probably the best approach for now.

HTML5 looks promising, but it'll be a while before it's widely supported. And even then it requires explicit user approval, which kind of limits the possibilities for using it (for example auto-redirecting to a country specific version of a website)

Eric Petroelje
A: 

For a start try the free http://api.hostip.info?ip=x.x.x.x (www.hostip.info for website)

It'll give you city and country in a xml structur. I've a small proxy-script writen in PHP on the http-server, which a html page calls with ajax and show the infomation in text and on a Google map using the Google geocoding api. Later on you can easy replace the api.hostip.info with an other api.

Martin Hoegh
For clarification, I use this for a sign up script where users are suggested a geolocation, which they can change by typing in a place or pick on a google map. The lat and lon are then stored.
Martin Hoegh
I just tried with my current IP. "Location: ... actually we haven't a clue. ". Am I just unlucky or is their database very small?
nute
Its community-based so the accuracy level may not be so high. My users are enabled to type in their location, so I don't how often the service fails. You may look toward some commercial geodatabases.
Martin Hoegh
I decided to go with www.GeoPlugin.com . Ever heard of it?
nute
No, but I just checked it out and it seems to offer a lot more like lat lon in the return data. It also offers different webservices.
Martin Hoegh
+1  A: 

Whatever you do please please please don't set the language of your website based on the user's IP, and then make it almost impossible to change unless you know said language and you feel like wasting hours (like ebay and paypal, among others, do). Use the browser's language.

Not everyone in, let's say, France speaks or wants to speak French.

I guess it's not very related to your question but i felt the need to rant about this, sorry :)

Andreas Bonini
Indeed unrelated, but thanks anyways. Yes I know I find it very annoying too when I travel and keep getting the wrong language.
nute
A: 

I would use IP address detection by default, and then optionally ask for a more specific location using the Javascript/HTML5 navigator.geolocation API when present. (For example, in iPhone Safari)

Most users are still using devices that don't know the location themselves, so plugins that are available will not get a better location than IP address detection does anyway. (Alternatively, they'll prompt users to manually enter data, which is annoying)

Joel L