Want to take the personalization of a page to the next level? Maybe you want to display a visitor's location on the page or pre-fill a city/ region form field.
Now you can using a FREE IP lookup database called GeoIP-DB and all it takes is a simple AJAX call and some basic JS. Even better, it's written for you!
You can see this in action (built in Unbounce) here:
WARNING: YOU ARE ENTERING DEVELOPER TERRITORY
Decide on the text you'd like to use to dynamically display the location information (the AJAX call will make available the country, region, city, latitude, and longitude information from a visitors IP).
Double click the text box and click the "view source" button in the bottom right. Wrap the text you wish to be dynamic with a span and assign the relevant class to display the location information. Here's a screenshot of what that would look like to display the city info:
City = "cityText"
Region = "regionText"
Country = "countryText"
Step 3. OPTIONAL Prefill Form Fields with Location Information
You can pre-fill a form field or preselect a dropdown (as long as the option exists) by adding some code to the script. Make sure the ID of your field in the form matches the ID in the code below (you can edit either or both to match):
Step 4. OPTIONAL Add a Google Map Displaying the Visitors City
Add a custom HTML widget to the page and paste in the following div tag:
Then paste in the following code into the script. Note you can change the size of the map by adjusting the "height" attribute of the iframe:
var frame = '<div class="embed-container maps"><iframe width="100%" height="481px" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?key=AIzaSyBvWSn-wEccZ_YSMG-xW7CfyaecyV1j0uA&q='+city+'+'+state+'" allowfullscreen></iframe></div>'
Want to take your Unbounce landing pages + convertables to the next level?
Check out the Ultimate List of Unbounce Tips, Scripts & Hacks