Skip to main content

How do I capture leads GeoIP location into the hidden form fields?

Hi there, 

At the moment, we don’t have any scripts or services in mind that can automatically capture the GeoIP and insert that into a hidden field. There used to be a javascript from MaxMind that offered this type of functionality, but they’ve since updated their offering and we’re not 100% sure if that will still work with Unbounce. You can find more info in this thread: /topics/geo_location_script 


Has anyone else in the community successfully integrated a way to track visitor’s location or GeoIP? If so, please share how you’ve done it!


Hi Justin 


Yes. My solution presented in the thread you mention (/topics/geo_location_script) can track the visitor’s location by using the MaxMind service. You can simply hide the form input field for the location and it still is going to update and save the location when a visitors submits a form. 


Cheers

Aleks


Aleksandar

I tried your method but it does not work for me.  How are you naming the country field.  Can you provide more detailed instructions.  I don’t need the automatic dropdown option, just the country when I receive a new lead.  Thank you.


Hi Veronica


Follow these steps:


Buy some queries at MaxMind. 


Create a form with a hidden field. Call the hidden field “country”. 


Put the following script into the “head” section of your landing page:



Put the following script into the “before body end tag” section: 



Change the form value in that script (#lp-pom-form-128) to the ID of your own form. 


Save everything. Done.


Now each time someone submits the form you will get his physical country location too.


Cheers

Aleks


Aleks, 


Thanks for the update! Much appreciated. 


BEWARE of GeoIP location.


I ran a test earlier this year with Maxmind to automatically determine the nearest location to the visitor. We have college campuses across California, on average about 100 miles apart. Even factoring Maxmind’s confidence factor it was extremely unreliable. Sure we’d get pretty consistent matches, but then we’d get results that were 84% confident the person was in Hesperia but the user self selected a campus in Bakersfield… 150 miles away.


If the confidence was something like 15%, then we could just set a threshold confidence level and exclude those matches. But when it had high confidence but inaccurate matching, we just had to scrap the whole project and stick with user self selection.


That’s really interesting, Phillip. Do you think the issue could have been that the students were selecting campuses that were further away from where they were at the moment? As a rough example, if they’re selecting a campus that they attend (or want to attend in the future) but they actually live 150 miles away, and are still living at home. Could that be a possibility? 


Regardless, thanks for sharing your personal experience with this one. Accuracy could make or break this idea completely. 


Hi Aleks,


This was a few months ago, tried this version and doesn’t seem to work. I did some investigation and it seems Maxmind have a new script for Geo-locations.


() 


I’m not a programmer but this is the script I have to fill the form but it doesn’t work.



as you can see I’m looking for the city.


I have a Maxmind account and loaded the domain. Any help would be appreciated.


Cheers

Brendon


Hi Brendon


This should do: https://gist.github.com/alewolf/275278f1da379b56512d


Be aware that the accuracy on city level is lower than compared to country level.


Cheers

Aleks 


Hi Aleks,

First of all, thank you very much for your code. I can not make it work, you could help me? I’ve tried a thousand things. Thanks. http://forms.geek.education/tutores-biologia/ 


Hi Mauro


I’ve tested a query on your page and I got an error from Maxmind.


Have you purchased database access at Maxmind and set your domain in the settings?


Hi @C_sar_Mid_o,


The undefined response you are getting back might be due to implementation problems rather than not being able to detect the city.


Also keep in mind that on city level these services are not very reliable.


Best,

Hristian


Hello Hristian,


Thanks .


I know, i just need to receive one city to split contacts by north and south.


I have no problem if the service is not 100% reliable.


But not defined are creating problems for my team to manage contacts.


So my ideia is use for example to services and reduce undefined.


Any ideia?


Hi @Cesar_Midao,


You can, of course, use two services but that would only add to the load time of your page.


Maxmind’s service is probably the best one out there so my suggestion is trying to trouble shoot it, instead of adding one more service.


Did you purchase enough credits from Maxmind? Have you tried reaching out to their support?


Hi @C_sar_Mid_o


I’ve used this service before to write the country of a lead into a hidden field. It’s pretty accurate on a country level but not sure how accurate it’s going to be on a city level.


You can contact their support or run a few tests yourself.


Best,

Hristian


Just wanted to chime in and say that @Rob has published a new #unbounce-tips-and-scripts post about how to do just this by using GeoIP.




Hi Aleks,


I’ve used your code (shared on GitHub) to pull the metro_code to a hidden field and then to the CRM and it works perfectly for the pages, thanks so much for adding it! Do you know if it needs to be changed to use on convertables? Can’t make it work on the exit overlays.


Me neither 😦 I am trying to do the same thing but can’t get it to work on exit pop up


I haven’t tried it yet.

Do you have an example page I could have a look at?


Yeah check out this page here (WIP) https://pestpop.com/signup/


I’ve tried putting the script on just the page itself, on the page and the popup, and just the popup, and none of them work.


I can’t access that page: https://monosnap.com/file/aWs7JWvbhc7GpzTXC0M3g6swQmldmJ


Sorry - https://www.pestpop.com/signup/


Needed www


It doesn’t look like the MaxMind script is installed right now.

And looking that the popup code I can’t see why this should not be working. It would need some customization though. Have you tried it?


No I was using the script mentioned in this post: [How-to] Use Geotargeting to Display a Visitors Location on a Page


Ah. Ok. That one I can’t help you with.


Reply