A list of use cases for a good geoip API

We're not releasing this application without putting together a list of use cases where a good GeoIp API would fit. While many of our visitors simply use our service to check their ip address probably when using web proxies and VPNs, you know, just making sure it's working, there are many other implementations for such an API.

1. Redirecting visitors to another website

Think of Craigslist for example. If I were to visit their website, all the information is targeted at my country. A lot of stores use geolocation to redirect visitors to the appropriate store address if they're operating in multiple regions. Here's an example for a redirect to a subdomain done in expressjs:

var request = require('request');

app.get('/', (req, res) => {
    request('https://api.infoip.io/<visitor-ip>/country/code', (error, response, countryCode) => {
        if (!error && response.statusCode == 200) {
            return res.redirect('https://' + countryCode.toLower() + '.example.com');
        }
    })
});

2. Redirecting your visitors to an appropriate translation

If you're translating your website/application it makes a lot of sense to use a GeoIp service and try to be smart by redirecting a visitor to the proper translation. Why should you wait for them to search for your translation links when you can do this by default within 50 milliseconds (yeah that's how fast our API usually responds).

The example in reason #1 is perfectly suitable for this scenario as well. Very good use case for an online documentation and especially so for commercial projects. Playing little tricks like this one will certainly establish a better relation between you and your customers.

3. Restricting access to your website based on geolocation

I must admit I hate it when I see the "This content is not available in your country" message on a website but, think about it, makes perfect sense in certain scenarios. Maybe you're not selling your stuff to other clients besides those from your own country (for various reasons) and you want to save bandwith and resources.

4. Helping your customers by guessing most of the info you require

I'm a real advocate for good UI/UX and (subjectively speaking) I would have placed this at the top. I don't know if 1% of the websites where I shop various products do this when they should, it doesn't cost anything.

How about those lengthy forms that you have to fill in when purchasing something. Why do they ask so many questions without even attempting at helping out their customers. Here's a proper example of shopping experience done right (python/Django this time):

import requests

def checkout(request):
    r = requests.get('https://api.infoip.io/<customer-ip>')
    data = r.json()
    
    form = CheckoutForm(initial={
        'country_code': data['country_code'],
        'state': data['region'],
        'city': data['city'],
        'postal_code': data['postal_code']
    })

I would get even smarter than that and, based on his location, try to estimate shipment costs. Now here's a nice user experience that I would like to see on all websites. "Just enter your card sir, we took care of the rest"

5. Serving files from a server closer to the client

If you're offering downloads of any kind and serving out big files to your clients this should save you a ton of money on bandwith expenses and also improve your customer satisfaction. Serving from a location closer to the client means less transit for your data and higher download speeds for them. It's a win-win scenario that you should really make use of...no excuses here.

6. Integration within your application

Developing live support, analytics or any kind of marketing software that tracks visitors? If yes, you should do GeoIp. Your customers will most likely want to see the location of their own clients/visitors in real-time and attempt at better supporting them. A little flag next to their entry is better than a 1000 words sometimes.

7. Serving the right content

How about a news website. A big one that has a lot of content added daily but does a smart thing at targeting it the right way to their visitors. I can bet my money that you would highly increase your conversions when adding more local news that occurred in close proximity to the visitor. This means that your content would have to be much better organised in the backend/database to have metadata such as latitude and longitude of the location where each story took place and then, when a visitor comes in, you would have to ping our API, grab the lat/long and perform a query for the news that took place in close proximity.

Here's a very cool and super-simple way of doing this. First let's query a Redis database to retrieve the stories that took place within 50 kilometers of the visitor:

georadius nyc 40.7598464 -73.9798091 50 km
1 "A man attacked a pidgeon today in central park!"
2 "A cat was seen beating a dog in union square."
3 "..."

It's really not that hard to get smarter with your application. It's not really a hit and miss. 90% of the time the your assumptions can be spot-on while I will leave the remaining 10% for proxy users and probably wrong/mistaken data but 90% is a big number and, in many cases, can increase your revenues.