Detect visitors from EU countries

In this tutorial we demonstrate how to detect whether a website visitor comes from a European Union member country based on their IP address with client side Javascript code :

$.get("https://ipforensics.net/api/v1/origin?apikey=APIKEY", function (response) {
  if(response.meta_data.geolocation.in_eu){
    alert("By looking at this page you are agreeing to our use of cookies.");
  }
}, "jsonp");

Always reference the API endpoint for complete response result

Last updated