Personalize by Country
This example shows you how you can customize content on your site depending on the user's location.
1
// Getting the country name from the user's IP
2
$.get("https://api.ipdata.co?api-key=test", function (response) {
3
if (response.country_code == 'UK') {
4
alert("Special offer for all our users from " +response.country_name+ "!");
5
}
6
}, "jsonp");
Copied!
This example displays an alert with a special offer targeted at users from the UK.
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
Last modified 2yr ago
Copy link