Add GeoIP location automatically to a hidden form field?


#1

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


#2

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: https://community.unbounce.com/unbounce/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!


#3

Hi Justin 

Yes. My solution presented in the thread you mention (https://community.unbounce.com/unbounce/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


#4

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.


#5

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


#6

Aleks, 

Thanks for the update! Much appreciated. 


#7

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.


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

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. 


#9

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


#10

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 


#11

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/ 


#12

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?


#13

Thanks for this script. Work pretty well.

When someone open the landing page, count 1 query. But i just need to know the city when someone submit the form.

How i can do that?


#14

Hello,

I need some help.

I’m using maxmind service but i’m getting to many “undefined” for the field city.

It is possible to use this service at the same time with other service?

My idea is, if the result is “undefined” the code execute other service and insert the city in the correct field.

Can someone help me? :slight_smile:


#15

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


#16

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?


#17

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?


#18

Hi Hristian,

Yes I bought enough credits MaxMind, and I’ve tried to solve with MaxMind Support. But the problem is, the accuracy is not enough for my country and that’s why I get many not defined.

The load time can be a problem, but it’s a landing page, the time to open is just a second, so i don’t believe that i need to think to much about the load of the page.

But my problem is, i’m not a pro with javascript, maybe i need some help :slight_smile:


#19

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


#20

@Hristian,

You have the code you’ve used that insert the country into a hidden field?

thanks for your help