Jump to content

Dynamically change headline to include {CityName} based on IP Address


rwerner
 Share

Recommended Posts

Hello,

I am building a landing page on Wordpress and would like to use geolocation to change the headline based on user's IP address. I have tried this solution with Snoopi's API:

<h1><span id="location">{CityName}</span></h1>

<script>
    $('document').ready(function() {
        $.ajax({
          url: "https://api.snoopi.io/check?apikey=XXX", // XXX = API Key
          dataType: "jsonp",
          jsonpCallback: "unBounce" 
        });
    }); // Ready
function unBounce(json){
   $('#location').html(json.City + ", " + json.State);
}
</script>

**I am not using unBounce to build though and am not sure what to change that value to....? Any advice would be very helpful! 

Thank you!!

Riley

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...