TipueLondon

Home

jQuery

CSS

HTML5

Other

Support

Shop

About & Contact

Silent and easy geolocation with jQuery

Get your visitor's country, city and time zone

Silent and easy geolocation with jQuery

First published 16th Feb, 2015. Updated 1st June, 2015
The aim of this article is to show how, with a little jQuery, you can return the country, region, city, time zone, latitude, longitude and IP address of visitors to your site, and do it silently.

Demo

Country name:
Country ISO code:
Region:
Region code:
City:
Latitude:
Longitude:
Time zone:
IP address:

How it works

Use the jQuery .getJSON() function to make a request to freegeoip.net. This is a public HTTP API for developers to search the geolocation of IP addresses. You're allowed up to 10,000 queries per hour, and the service is free and open source.
With this method of geolocation the visitor isn't notified or asked to grant permission. The country codes are defined in ISO 3166-1. Some fields may be empty, depending on location. The latitude and longitude values are variable, so this probably isn't the way to go if you want exact positioning; but it is easy, silent and free.
© 2016, Tipue. Made in London.
About   Privacy   T&Cs