Solutions for finding website visitor's geolocation

此生再无相见时 提交于 2019-12-06 06:01:25

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.

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.

databyss

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?

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)

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

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