What is an IP Address?
Each computer connected to the internet has an IP address. You can find out your computer’s IP address from websites like https://whatismyipaddress.com/. You may even see a map of your general location on that site. So - how did the website figure out where you are located based on your IP address? Your Internet Service Provider (ISP) owns blocks of IP addresses. Each block of addresses enters the internet from known locations owned by the ISP, and the IPs are mapped to these points. Since ISPs generally get customers to the internet from the nearest location, the IP address generally gives a pretty decent geolocation of the user. To be clear, this is not your Google Maps geolocation to a street corner - it is more of a city-level identification. For example, it will identify you as near Los Angeles, CA - but not your neighborhood, street, or distinct address.
Use Cases for Geolocation
One killer use case for geolocation is shopping. When shopping for products, it is nice to know what the local store has in stock. Let’s look at two popular e-commerce websites, one that does not use IP geolocation and another that does:
Open an incognito browser window (to ensure no cookies or user information are being sent). Browse to bestbuy.com. When you land on the page, you are asked to share your location:
This client side request will use your device’s location settings to share where you are located in the world (which is much more precise than geoip location- and probably more information than Best Buy needs). This is cool, but many users intuitively deny the location permission and the dynamic experience is lost.
Now, do the same for HomeDepot.com.
When you browse Home Depot’s website, it automatically knows the closest store to you, gives you the hours, and sets the search to help you find the inventory at the nearest store. What an incredible experience! Home Depot is likely using IP Geolocation to create a dynamic site based on the user’s location. By automatically determining the user’s location on the server, the website becomes immediately more useful - you do not need to manually allow for location, or enter your zip code. This experience likely leads to higher conversion rates - visitors are instantly ready to begin searching the local store.
Other ideas that leverage geotargeting experiences:
- Currencies: You can charge in £, $, €,¥ based on the country code provided from the location data. You can even change the pricing models, or offer different products based on country.
- Internationalization (i18n). If a user is in Germany, you may serve the German language site. Some sites add the flag in the corner so that you know you are correctly geolocated.
- Greetings: If you know their geographical location, you also know the timezone, and you can add a greeting “Good Evening” or “Good Morning.”
- Content access. Netflix may own the rights to show the Great British Bakeoff in the USA, but not in the UK. By identifying where in the world a user is, they can dynamically display different content that is customized to the visitor’s location, complying with their legal responsibilities.
- Redirects: https://bbc.co.uk redirects to bbc.com for visitors from the USA.
Enabling Geolocation on my website
Ok, so you are sold - you want to add geolocation to your website to create customized user experiences based on their location. Several APIs can convert the IP address to a location. Let’s have a look at the AbstractAPI Geolocation service. Here are the steps to get started with the Abstract API Geolocation service:
- Get a free API key by signing up for AbstractAPI. Click the IP Geolocation API link on the main page. Your API key will be shown on the screen.
- Retrieve your IP address. Use a service like https://whatismyipaddress.com/.
- Using you API key and your IP address, create a URL with the following format:
- Open that URL in your browser, and you’ll see a JSON output with a multitude of information. An example response is below:
From the IP Address, we know that our user is in Belgrade, Serbia, approximate latitude and longitude, the timezone, currency, and even links to an image of the flag (useful to show that the site is being personalized by country).
Now you can make a call to the Abstract API endpoint with your API key, and get the details of the location. Based on the results, you can customize the page for your visitor.
Can the Geolocation be spoofed?
Yes. A VPN would make the user appear to be in a different location. I used a VPN to appear as if I were in New Jersey when visiting Home Depot, and to appear as if I were in Serbia for the API call above. VPNs are often used to get around location-based access control (watch movies, listen to music unavailable in your region).
Can the Geolocation be incorrect?
Yes. When living in England, I have seen my geolocation appear as if I were in Glasgow (300 miles away). Correct country, but the weather forecast would have been terrible.
Users of Starlink, a satellite-based internet service, all have IP addresses that geolocate to New York City. For these users, the geolocation experience might even be negative - they are not interested if the Home Depot in Manhattan has toilet plungers in stock. You will need to offer users the ability to change the location.
IP geolocation data provides the ability to deliver website content that is dynamically created for the location of your visitor. This customization improves the user experience by presenting data that is relevant to the visitor. In this post, we have shown how e-commerce sites use IP addresses to choose the default store, change currency, and deliver different products based on location. Sites like Netflix can deliver content that is legally available for a location. Using an IP Geolocation Service like that from AbstractAPI allows for geographic-based content to be easily customized with no user interaction. Try it today on your site!