Solutions for finding website visitor's geolocation

人盡茶涼 提交于 2019-12-08 02:22:21

问题


I am aware that there are many services which provide geolocation tools for working out where users are visiting from. The website I'm working on is an e-commerce site which runs in multi-territories. When a visitor hits the website it should work out where they are from and show the relevant currency/language for the user.

In the past we have used maxmind but I'm wondering if there are better solutions out there. I'm calling out to developers with experience in this area to share their knowledge and expertise on what's available and what the pro's and con's are of various solutions.

Additional info: The website in question runs mainly on a combination of Java (Spring) and PHP (Kohana), so libraries for either of those can also be considered. We already have a solution for working out which currency to use provided we can obtain the ISO code of the visitor's country.


Update
Thought I'd leave a rough explanation of the outcome for anyone who visits this question.

Geolocation: I've used freegoip for detecting user location as suggested in this thread.
Language: When working out which language to use for the user I have used PHP to check the language set in the user's browser: http://www.php.net/manual/en/function.http-negotiate-language.php


回答1:


I've been working on a project that requires geolocation, unfortunately I find that most services are working on MaxMind database , at last I used freegeoip , free and so far precise in my region.

Regards.




回答2:


On a small-ish ecommerce site I worked on we used Akamai to provide geolocation data which would serve customized advertisements and prices based on which state the visitor was in. Check this out for more information: http://www.akamai.com/html/technology/products/personalization.html.




回答3:


For the language, it should come through from the browser. That's more useful and more accurate than geolocation.

For example, if you were traveling with your laptop and you used the internet, you'd probably want to see things in your language than the native language of the country you were in.

Look at this question for more information: Checking browser's language by PHP?




回答4:


Another option is the http://ipinfo.io API (my own service). Here's an example of what the API returns.

$ curl ipinfo.io/8.8.8.8
{
  "ip": "8.8.8.8",
  "hostname": "google-public-dns-a.google.com",
  "loc": "37.385999999999996,-122.0838",
  "org": "AS15169 Google Inc.",
  "city": "Mountain View",
  "region": "CA",
  "country": "US",
  "phone": 650
}

You can also query for specific fields, such as country in this example:

$ curl ipinfo.io/8.8.8.8/country
US

More details are available at http://ipinfo.io/developers. It's free for up to 1,000 requests per day and you can signup to a paid plan beyond that (see http://ipinfo.io/pricing)




回答5:


As I mentioned we built https://ipdata.co for this exact usecase

$ip = '78.8.53.5';
$details = json_decode(file_get_contents("https://api.ipdata.co/{$ip}"));

This will return

{
    "ip": "78.8.53.5",
    "city": "G\u0142og\u00f3w",
    "region": "Lower Silesia",
    "country_name": "Poland",
    "country_code": "PL",
    "continent_name": "Europe",
    "continent_code": "EU",
    "latitude": 51.663,
    "longitude": 16.0757,
    "asn": "AS12741",
    "organisation": "Netia SA",
    "postal": "67-200",
    "currency": "PLN",
    "currency_symbol": "z\u0142",
    "calling_code": "48",
    "flag": "https://ipdata.co/flags/pl.png",
    "time_zone": "Europe/Warsaw"
}

This has a number of Ecommerce relevant datapoints, specifically

  • Currency Symbol
  • Currency Code
  • Country Flag Icon
  • Country Calling Code

The currency symbol z\u0142 is ASCII for the Zloty



来源:https://stackoverflow.com/questions/11367264/solutions-for-finding-website-visitors-geolocation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!