views:

452

answers:

3

Title says all. ;)

How can I tell the nationality of a user of my web site based on client ip?

Edit: Like commented, this question have been answered before:

http://stackoverflow.com/questions/283016/know-a-good-ip-address-geolocation-service

+4  A: 

use the GeoIP databse. there is a free one. there are also a lot of GeoIP webServices you can use.

Joachim Kerschbaumer
A: 

If you're thinking localization, let the user choose the correct language instead of doing it automatically -- or at least provide an easy way for them to change it and make it sticky via cookies. You can do ok most of the time at guessing using GeoIP, but sometimes you'll get it really wrong. Google sometimes sends my wife to the German version of their web site even though we're in the middle of the US. Using anonymization services (like TOR) will also likely result in guessing errors. Having the option to choose and keeping the choice on the computer will make it a better experience for your users.

tvanfosson
A: 

Besides the already mentioned GeoIP database, you could also use IP2LOCATION service. It's a paid one but it will also work.

Keep in mind that all these services will give you an estimate of the location but not a very accurate geographic position. I read a networking paper once stating that this is an impossible task to accomplish (give an accurate position of an IP address).

Pablo Santa Cruz