Skip to content

Instantly share code, notes, and snippets.

@RobertCam
Created June 27, 2017 03:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertCam/c3d24fccbcaabe7148d6416cecefe88b to your computer and use it in GitHub Desktop.
Save RobertCam/c3d24fccbcaabe7148d6416cecefe88b to your computer and use it in GitHub Desktop.
Display a visitors location on an Unbounce page (country, city, region, and coordinates)
<script>
$.ajax({
url: "https://geoip-db.com/jsonp",
jsonpCallback: "callback",
dataType: "jsonp",
success: function( location ) {
var country = location.country_name;
var region = location.state;
var city = location.city;
var lat = location.latitude;
var long = location.longitude;
// add classes to display location info on page
//City
$(".cityText").text(city);
//Region
$(".regionText").text(region);
//Country
$(".countryText").text(country);
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment