Set defaultCountry to 'auto' and pass in a function for geoIpLookup to perform a JSONP request to ipinfo.io, which returns the user's country based on their IP address.
<input id="phone" type="tel">
$("#phone").intlTelInput({
defaultCountry: "auto",
geoIpLookup: function(callback) {
$.get('http://ipinfo.io', function() {}, "jsonp").always(function(resp) {
var countryCode = (resp && resp.country) ? resp.country : "";
callback(countryCode);
});
},
utilsScript: "../../lib/libphonenumber/build/utils.js" // just for formatting/placeholders etc
});