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

Can you share the code you are using for this?

Hi Rob - Thanks for sharing this script. Just installed and it’s working great.

Two quick questions if you’re ok to answer that would be awesome:

  1. Where exactly would I “paste the following code into the script”? This is in reference to the “Add a Google Map…”

  2. Likewise where exactly would I add the “Prefill Form Fields…” script.

I’ve got it to work (basic geo script) so thanks! But, I’m not a coder so dunno how to merge the other two scripts you’ve kindly provided.

Thanks a bunch!


@Akkysia great questions! This can be a little bit tricky if you’re not familiar with javascript, but you’ll want to place both the map and prefill snippets at the end of the function but not outside of the closing brackets });

Here’s a screenshot of what it looks like on the example page. You can see that the prefill and map snippets are near the bottom but still inside that function that’s pulling in the location from GeoIP-DB

Hope this helps!

1 Like

Hi Rob - It does. Let me get that onto the page and switch it on! Thanks again!

It seems that AJAX Requests are blocked and this not achievable anymore. Please let me know if I’m wrong!

Hey everyone, are you guys also having issues with the Geo IP not working or is it just me?

If you open up the geoip page, you’ll see a notice that they had to move domains.

The documentation on their new site provides the new address that’s needed to make a call to their service.


Thanks for checking on this Hristian, great catch! I’ve updated the original post with the new URL that needs to be used (https://geolocation-db.com/json) and updated the link to their website in the post description. Thanks again!

1 Like

Thanks for the quick response!

Hey Rob, Actually after updating to the new URL, script stopped working. I found out that my issue was the Wifi I was using prior, and not the URL. Do your own investigation, but I believe the old URL works fine.