If I want to provide a website with location appropriate content, what ways can I use to find the visitor's rough location using their IP or header information?
|
|
Firstly, you should know that the accuracy of these services is, and always will be, low. MaxMind Geolite city is free. If it is not good enough, you can apparently upgrade to a more accurate paid-version. I can't speak for the quality of the paid version, as I have never used it. If you like your SQL, download the CSV version. Load it into your database of choice, and query away. The faster and space-efficient option is to download the file binary blob version of the same database, and then use a language specific API from the same website to query it. Alternatively, I have found ipinfodb.com to be useful. Query is by simple HTTP GET. For example, to geolocate stackoverflow.com try:
This will return an XML file containing latitude and longitude, that looks like:
|
|||
|
|
|
The location you can infer from IP isn't very reliable (i.e. it kinda works sometimes). If you want a reliable location, consider the geolocation API that is part of HTML5. Note, however, that not all web browsers support it (yet). |
|||||||
|
|
An option that focuses on mobile support, though also works well on most desktop browsers (except for IE in my experience), is the Geo-Location-Javascript package which wraps the HTML5 GeoLocation API Sean mentioned. I found the mobile browser support pretty poor for the HTML5 API (not surprising, though, since it's still in draft) so that's why I went with this package. The results from moblie devices are quite good over cell and WiFi connections (and GPS if the device has it). Desktop browsers report a pretty coarse-grained position comparable to other services. |
|||
|
|
|
You can use this url and pass it an IP address. http://api.hostip.info/get_html.php?ip=84.32.32.44 |
|||
|
|
|
Quova http://www.quova.com/ also has a service. I spoke to them yesterday at GeoLoco. According to the them (so take it with a grain of salt) they say they are much better internationally than MaxMind. They are about equal in North America. Be aware that for mobile phones the IP will probably map to wherever the Operator has their gateway to the internet. You can also try using - http://www.loc-aid.com/ if you are targeting mobile phones. |
|||
|
|
|
Google analytics provide basic maps and statistics on your visitor's location. Of course, you have to share this information with Google... |
|||||
|
|
ipinfodb.com is good but they are currently offline :( I am using that to my api. It is great for my weather, but i don't know now it has been offline since yesterday. |
|||||||||
|
|
If you want to provide them content or ads based on their geographical location you can't rely to take the location data from the device. Even they are on mobile phones there is a high chance that they have GPS and wifi turned off, and they have to give their consent to share the location. It is like: "Hey, can you share your location with me so I can give you content and ads that I think are most related to your geographic location?" Response: "No! Give me the best content and ads you have out there" The only way to find the location without asking them for permission is trough their IP Address. You can install a database on your own server and query it to find the location of an IP Address or to use an external API that you have to query and get the results. I am using ipgp geolocation api and working great. ( http://www.ipgp.net/ip-address-geolocation-api/ ) |
|||
|
|
|
try to use google analytics, that gives you all data related with you homepage, where it come, how many UNIQUE visitors you have and wher |
|||
|
|
protected by whuber♦ May 10 at 13:16
This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.
