[How-to] Use Geotargeting to Display a Visitors Location on a Page

widget
add-on

#41

Hey @Rob , Just tried this out and as far as I can tell it should be working. Can you take a look and let me know what’s going wrong? I’m really trying to pre-populate zip code into a field but I can’t seem to get even the display text to work. http://specials.zendyhealth.com/test-bed/


#42

Hi @Justin_Frech I had a look and there were some syntax errors in the code (a few stray < > and a couple of missing ‘$’). I’ve fixed those for you and saved and it appears to work in Preview. Have a look and if you’re happy you can republish the page.


#43

I just tested it and it thought I was 113 miles away, so maybe not for me :slight_smile:


#44

ok, but there is any way to display a section (not just some small text) only to one country?

thanks


#45

Is it possible to update a button with the user’s location?

For example, a button would read “Request a Demo in {cityText}”


#47

Hi @mike22rtn This is an awesome suggestion! It should be possible with some tweaks to the code above to target a button label. It might be tricky to only swap a section of the label due to how the Unbounce builder generated buttons. It would be easier perhaps to use a text link and you can edit the source code directly in the builder and add some <span> tags to target specific text.

A sneaky little workaround to still have it look like a button would be to layer the text link over the button and remove the button’s actual label. To the visitor the text link would still look like the button label.

I’ll try and find some time to add this into the existing workaround in the near future as it shouldn’t be too difficult


#48

Hey @Rob - this is great!

Is there any way to use it to show specific fields? Use case example is GDPR consent check box for EU visitors.

Would love it if we can show/hide this field depending on where visitor is located.


#51

Is there a way to make the “fallback” text say something other than “not found” in the event the script can’t find a city, region or country name?


#52

whoa !

a big thanks for this big tips !!! :smiley: