How to find users' location during a web site visit?

You can use GeoIP location services, who have various levels of accuracy. There may be other providers of IP-location databases too.

Another option is to try to use HTML5 location services, such as in http://html5demos.com/geo and http://dev.w3.org/geo/api/spec-source.html.


You need to use an IP geo/co-location API such as this one and many others. This one boasts a free service requiring only registration.

You can also download databases with geo code information. This will work to certain resolution but the db represents a static snapshot and reality may veer significantly over time. Here is a freely available CSV file that could get you started on the local db side of things. The CSV file (which is a bit old, was last updated August 2009) contains 59,000 entries.