Subscribe to a Premium Development Newsletter by TheDevCouple! What is TheDevTakeaway?

Locating your site’s visitors can come in handy whether you are implementing purchasing power parity for your SASS or customizing content, currencies, and advertisements according to their location. It helps you tailor the content to visitors from different parts of the world.

Locating and tracking site visitors is a hassle, but not anymore. IPStack is super handy when it comes to handling all the geo-related tracking of your audience.

Last year, Ahmad Awais built an open-source Covid19 tracking tool, corona-cli. It displays the latest stats of the disease throughout the world. If we were to take it further, we could include IP tracking to automatically show information relevant to the visitor’s country so that the users won’t need to specify their country manually. Pretty neat, right? I can think of many more use-cases like these from the top of my head. I am sure you can too. 

To implement site visitors’ tracking and identification, you need a geolocation API. IPAPI by ipstack is the one I recommend because of its extensive information without compromising performance. Not only that, I went through some user reviews, and it turns out it is pretty accurate as well.

With that said, let’s jump in and see how we can use IPAPI to get location-related information. 


⚡️ Information provided by IPAPI

The data provided by the API is categorized into location, currency, timezone, connection, and security modules. For visitor tracking and identification, you only need the first three modules. These modules provide information-based features that ipstack offers. Here is a brief breakdown:

  • 📌 Location: It includes all the location parameters like region, city, etc.
  • ⏰ Timezone: It gives the Time zone of the visitors and time-related metadata.
  • 💵 Currency: Information about Primary currency, code, symbol, and more. 

Enough talk. Let’s see the API in action now. 

Ipapi Thedevcouple

💻 Working with IPAPI

First, go ahead on the IPAPI or ipstack website and sign up using a free or a premium plan as per your requirement. Once you have successfully signed up, you will be redirected to the quick-start guide page. 

Step 1 – API Access Key

The first thing you will see is your API access key. Copy it and store it somewhere, as we will use this key to make API calls.

ipstack Quickstart

→  Step 2 – Requesting the API

The next step is requesting the API for IP-related information. The API provides you three lookup options:  

  • Standard Lookup: Gets data for a single IP Address.
  • Bulk Lookup: Gets data for multiple IP Addresses
  • Requester Lookup: Gets data of the requester.  

Using any of these endpoints is pretty straightforward. You can find more about them in the documentation. For our testing, we will use the standard lookup method. The quick start guide conveniently creates the API endpoint using your IP address and your access key.

ipstack Quickstart 2

Now, you can open the API endpoint/link in a new tab to see the response. If you are using a free plan, you will get a response like this: 

"ip": "2400:adc7:901:c900:552c:21b1:----:----",
"type": "ipv6",
"continent_code": "AS",
"continent_name": "Asia",
"country_code": "PK",
"country_name": "Pakistan",
"region_code": null,
"region_name": null,
"city": null,
"zip": null,
"latitude": 30,
"longitude": 70,
"location": {
"geoname_id": null,
"capital": "Islamabad",
"languages": [
"code": "en",
"name": "English",
"native": "English"
"code": "ur",
"name": "Urdu",
"native": "اردو",
"rtl": 1
"country_flag": "",
"country_flag_emoji": "🇵🇰",
"country_flag_emoji_unicode": "U+1F1F5 U+1F1F0",
"calling_code": "92",
"is_eu": false

As you can see, the response in the free plan includes the location module and gives location information according to different parameters. If you are subscribed to their Basic plan or higher, the response will additionally include Currency, Timezone, and Connection modules. To give you an idea, it will look like this: 

    "ip": "",
    "hostname": "",
    "type": "ipv4",
    "continent_code": "NA",
    "continent_name": "North America",
    "country_code": "US",
    "country_name": "United States",
    "region_code": "NY",
    "region_name": "New York",
    "city": "Brooklyn",
    "zip": "11238",
    "latitude": 40.676,
    "longitude": -73.9629,
    "location": {
        "geoname_id": 5110302,
        "capital": "Washington D.C.",
        "languages": [
                "code": "en",
                "name": "English",
                "native": "English"
        "country_flag": "",
        "country_flag_emoji": "🇺🇸",
        "country_flag_emoji_unicode": "U+1F1FA U+1F1F8",
        "calling_code": "1",
        "is_eu": false
    "time_zone": {
        "id": "America/New_York",
        "current_time": "2018-09-24T05:07:10-04:00",
        "gmt_offset": -14400,
        "code": "EDT",
        "is_daylight_saving": true
    "currency": {
        "code": "USD",
        "name": "US Dollar",
        "plural": "US dollars",
        "symbol": "$",
        "symbol_native": "$"
    "connection": {
        "asn": 22252,
        "isp": "The City of New York"
    "security": {
        "is_proxy": false,
        "proxy_type": null,
        "is_crawler": false,
        "crawler_name": null,
        "crawler_type": null,
        "is_tor": false,
        "threat_level": "low",
        "threat_types": null

Step 3 – Integrate into your application

Now that we have seen what kind of information we can get, we can utilize it in our applications. IPAPI’s JSON and XML API design makes it super easy to integrate into your application.

For a fun, quick demo, I coded a simple React application. The idea is to show the user’s country flag emoji alongside their name using IPAPI. Your application might differ; therefore, this is the only piece of code you need to worry about. I am sending a GET request through Axios on the API endpoint and then used an IP address and my access key. The response is received and stored in the data variable.

// importing axios in the file
const axios = require('axios');

// function making the api call
(async () => {
    await axios
        .then(({ data }) => console.log(data))
        .catch((err) => console.log(err));

 As we can see from the previous response, the country emoji resides in the location module. So, I extract the country emoji using data.location.country_flag_emoji and then pass it to my front-end code. Here is the result, with the country emoji being shown to the visitor:

Ipstack Country Emoji

Pretty cool. 🤩 This was a quick tutorial on implementing visitor tracking and identification on your site using ipstack API. I leave the rest up to you and your imagination to utilize it according to your use case. 

🔥 Performance

When it comes to integrating APIs like this in your application, performance is the biggest concern. No one wants their site to hold off on content while waiting for the API to respond. I ran a few tests to check the performance of IPAPI. 

⚡️ On the first test, I got an awe-inspiring response time of 187ms

🚀 I then tested for different endpoints and the response time never went above 200ms.

What do these numbers translate to? Close to zero impact on your page loading speed which is very impressive. 💯

Wrapping up

With an uptime of 99.759 for the last 90 days, IPAPI is a reliable and quick way to introduce location, time zone, and currency-related features in your application. 

It has been my go-to choice for implementing features like these in my projects. So far, my experience with IPAPI has been outstanding. So, if you are looking to buy something like this, definitely give it a go. 

Have you used IPAPI or any similar service to drill user’s information? Which service did you use, and how was your experience? Let us know your thoughts in the comments section below. 

We’ve written a whole series of extensive reviews featuring IPStack and its other products. Feel free to check these out here →



A Premium Development Newsletter by TheDevCouple! What is TheDevTakeaway?

DevKinsta – One Suite For All Your WordPress Development Review – Get User Location Data In An Instant Rank Math Plugin For Your SEO Needs
There are currently no comments.

🙌 You must have something to say here...