Look Up IP Geolocation from Zoho Creator with Deluge

Add IP Geolocation Data to Zoho Creator Records

A web form gives you an email address and an IP. The IP is worth more than people think — it tells you the city, the country, the timezone to call in, and the ISP, which is often the difference between a real prospect and a bot. One request enriches the record.

The vendor in the original no longer exists. api.ipaddresslabs.com returns NXDOMAIN — the hostname does not resolve at all — and the parent domain ipaddresslabs.com now redirects to an unrelated site. There is no migration path; the service is simply gone. This article uses ipwho.is, which is free, keyless, HTTPS and returns a richer payload. The original also had two code defects: it parsed a JSON response with executeXPath, and the function was declared to return a string but had no return statement at all, so it always returned empty.

This article merges two library entries. “Geolocation data API Integration” and “Ipaddress Labs to Zoho Creator API Integration” described the same vendor doing the same job — the second had no script at all. They are one article now.

Before you start

  • A form with an IP_Address field and somewhere to put the results.
  • No account, no key. ipwho.is is free for reasonable volumes.

Deluge function

// ============================================
// IP GEOLOCATION -> ZOHO CREATOR
// No key required.
// ============================================

void Enrich.geolocate(int recordId)
{
    rec = Leads[ID == recordId];

    ip = ifnull(rec.IP_Address,"").trim();
    if(ip == "")
    {
        info "No IP on record " + recordId;
        return;
    }

    response = invokeurl
    [
        url  : "https://ipwho.is/" + ip
        type : GET
    ];

    // ipwho.is reports failure in the body with HTTP 200
    if(response.getJSON("success") == false)
    {
        info "Lookup failed for " + ip + ": " + response.getJSON("message");
        return;
    }

    rec.Geo_City       = response.getJSON("city");
    rec.Geo_Region     = response.getJSON("region");
    rec.Geo_Country    = response.getJSON("country");
    rec.Geo_PostalCode = response.getJSON("postal");
    rec.Geo_Latitude   = response.getJSON("latitude");
    rec.Geo_Longitude  = response.getJSON("longitude");

    connection = response.getJSON("connection");
    if(connection != null)
    {
        rec.Geo_ISP = connection.getJSON("isp");
    }

    timezone = response.getJSON("timezone");
    if(timezone != null)
    {
        rec.Geo_Timezone = timezone.getJSON("id");
    }

    info "Located " + ip + " -> " + rec.Geo_City + ", " + rec.Geo_Country;
}

Notes

  • Check success, not the status code. A bad or private IP still returns HTTP 200 with success: false and a message. Without that check you silently write nulls over good data.
  • Avoid ip-api.com. It is widely recommended, but its free tier is HTTP only — the HTTPS endpoint returns “SSL unavailable”. Using it means putting your visitors’ IP addresses across the internet in clear text.
  • City-level accuracy is a hint, not a fact. IP geolocation is reliable at country level and rough at city level. VPNs, mobile carriers and corporate proxies all move the apparent location. Use it to route and prioritise, never to make a decision the person would dispute.
  • Geolocation is personal data. Under GDPR an IP address is personal data and so is the location derived from it. Have a lawful basis, and do not store more than you use.
  • Enrich once, on create. The location for a given IP does not change between form submissions. Re-running on every edit just burns your rate limit.

This script is part of the free Creator Scripts Deluge Library.

All 39 Deluge scripts, the full Zoho Creator course, and every downloadable asset are now free. Get free access →