Content Personalisation

This example shows you how you can customize content on your site depending on the user's location.

// Getting the country name from the user's IP
$.get("https://ipforensics.net/api/v1/origin?apikey=APIKEY", function (response) {
  if (response.meta_data.geolocation.code == 'NG') {
    alert("Special offer for all our users from " + response.meta_data.geolocation.name + "!");
    }
}, "jsonp");

This example displays an alert with a special offer targeted at users from Nigeria. You can drill down and target users by a more specific location such as;

  • Region

  • City

  • Postal Code You can also customize your site based on;

  • The user's timezone

  • The user's currency - eg. on your pricing page or shopping catalogs

  • The user's language - we recommend getting the user's language from their Browser settings, however as a fallback you could use our language field to determine the user's likely language

Always reference the API endpoint for complete response result

Last updated