IpForensics
HomeGoto Dashboard
  • 📖Introduction
  • Protocols
    • HTTP Json Protocol
    • Response headers
    • Error Codes
  • Features
    • Pay-As-You-Go
    • API Security
    • HTTPS
  • Api Response Data
    • 📶Mobile Carrier
    • 🏥ASN
    • 📊General
    • ⏲️Timezone
    • 💵Currency
    • 👨‍💻Threat Detector
    • 🌐Company
    • 🌏Geolocation
    • 🌍Advance Geolocation
    • 💻Device Information
    • ✈️IATA/ICAO
  • API
    • 🚀Intro
    • 📊IP & Threat Intelligence API
      • Single Lookup
      • Origin Lookup
    • 💹Exchange Rate API
      • Currency Endpoint
      • Live Rate Endpoint
      • Historical Rate Endpoint
      • Currency Conversion Endpoint
      • Currency Swap Endpoint
  • Code Implantation
    • Block Automated Visits From Hosting Providers
    • Block VPN/Proxy and Tor users
    • Redirect by Country and Location Offers
    • Content Personalisation
    • Get the location from an IP Address in Javascript
    • How to get a client's IP address using JavaScript
    • HTML5 Geolocation with IpForensics fallback
    • Blocking Users by Country
    • Detecting Users Currency or Currency Personalisation
    • Preventing Free Trial Abuse
    • Device-Based Ads and App Binary
    • Detect Users Device/Computer and Operating System
    • Detect visitors from EU countries
    • How to detect and prevent credit card fraud
    • How to convert amounts to website visitor currency
  • MISC
    • Changelog
    • FAQs
    • Troubleshooting
    • API Status
    • Rate Limits
Powered by GitBook
On this page

Was this helpful?

  1. Code Implantation

Redirect by Country and Location Offers

PreviousBlock VPN/Proxy and Tor usersNextContent Personalisation

Last updated 2 years ago

Was this helpful?

This example shows you how to redirect users based on their country. You could for example redirect the user to a country-specific store from your international store.

You can also send location-based offers to your users/audience based on their IP or country

// Getting the country code from the user's IP
$.get("https://ipforensics.net/api/v1/origin?apikey=APIKEY", function (response) {
  if (response.meta_data.geolocation.code == 'NG') {
    window.location.href = "https://ipforensicsstore.ng";
    } else if (response.meta_data.geolocation.code == 'DE') {
    window.location.href = "https://ipforensicsstore.de";
    } else if (response.meta_data.geolocation.code == 'GH') {
    window.location.href = "https://ipforensicsstore.gh";
    }
}, "jsonp");

Always reference the for complete response result

This example will redirect users from the Nigeria to , users from Germany to and users from Ghana to .

This an incredibly common usecase for geolocation.

API endpoint
https://ipforensicsstore.ng
https://ipforensicsstore.de
https://ipforensicsstore.gh