Country Code from IPGeolocation into localization.country.iso_code liquid

I can (I believe) get a visitors country code using something like

jQuery.getJSON('https://api.ipgeolocation.io/ipgeo?apiKey=API_KEY', function(location) {

with my API key, and then modify content in my product templates using

{% if localization.country.iso_code == 'XX' %}

but how do I get the country code put out by the first piece of code, recognised by the localization liquid code?

I just want to replace the Add to cart button when someone visits from a specific country.

Any help with this would be much appreciated!