Created
June 27, 2017 03:37
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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