Does this work if you are using cloudflare?
Cloudflare transmits the IP address in the CF-IPCountry header variable.