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



Show first post

86 replies

Amazing as usual, @Rob. :cage:

We tried using a paid service (MaxMind) to locate our visitors and match them to the nearest campus. It was not accurate enough for us to implement it. See the thread below for more details.

I would be interested in learning about the accuracy of GEOIP-DB. My guess is that if it’s free, it’s less accurate than paid services.

Hi Rob,
Thank you for adding this feature. I am not sure what I am doing wrong, but I can not get the city name to show up no matter what. I copied and pasted the java script in the page and used exactly the same format in the text replacement and nothing shows up. I would appreciate any help,

Regards,

Userlevel 6

Hey @Samir sorry to hear you’re having some trouble. I’m happy to take a closer look for you. Could you share the URL of your page and I’ll have a look for you.

hey @Rob, thank you for taking time to look into this. here is the test landing page: http://unbouncepages.com/test-geo/
Please note that I also added the optional map and that is not showing up in my page either.
Any help will be appreciated.

Thank you,

Hi @Rob, Thanks for fixing the map, however the city name is still not showing up in the title. Can you please take a quick look at that too?

Thanks so much
Samir

Hey @Rob, sorry to bother you again. Any update on the location/City name not showing up in the headline issue? Thank you!

Hi @Rob, Thank you for this great information, Yes you were right! For some reason, our IP is not allowing the location to show.
Once I put it on LTE on my phone I was able to see the location, however the location name it is showing me (and my colleague’s mobile device) is about 65 miles away! I am not sure if this is due to iphone’s location identifier on our phones, but since majority of today’s users convert on their mobiles, if we can do a more generalized region name it will be more helpful, otherwise, this information might actually hurt the conversion rather than helping it.

Thanks again, and if you have any suggestions will be glad to hear them.
Regards

Userlevel 6

Mobile traffic will definitely be less accurate due to the way mobile networks work, especially for smaller towns that are close together (often sharing a single cell tower). For example you could be connecting via a cell network in that city 65 miles away.

There is a more general region available though. All you need to do to access that instead is change the class of your span tag to be ‘regionText’ instead of cityText and you’ll be all set 🙂

Hi @Rob, Thanks so much. I will try the region option for sure.

Best,

Hi @Rob

This is a super feature. But I’ not seeing it work for me.

The page is http://carehomes.fshc.co.uk/care-homes-england/ and I’m looking to use geo-targeting to improve the relevancy of the page to visitors from AdWords.

Additionally, I’ve inserted the map element which I’d like to use.

The script says .cityText whilst the span codes use cityText. Could that be the issue.

Could you be so kind as to view the page, the script and make a recommendation please?

Thank you

Userlevel 6

Hi @Carl_Duncker! I’ve had a look and there was a small syntax error in the code you had in script manager (the map code was sitting outside the main function which was throwing an error). I jumped in and fixed that syntax issue for you and the script is working now.

One thing I noticed though is that the length of the text for my region was causing a display issue in the headline as there wasn’t enough space for it to display in place of “England”. Here’s a screenshot so you can see what I mean: https://www.screencast.com/t/3kZTeUH9d

I disabled the script in script manager for now until you have a change to play around with the spacing for text on the page. It’s working now though and is still in the account, just not being applied. Once you’re ready just hop into script manager and enable the script to have it start working.

Let me know how it goes!

That’s great. Thank you.

The geo-location is working but the embeded map isn’t. It simply doesn’t show. The custom html is there though.

Can you help?

Many thanks,

Any joy @Rob?

Thanks

Userlevel 6

Hey @Carl_Duncker my colleague @Noah figured this one out! Looks like you’ve got two different div tags with the #map-container ID on the page and one is currently hidden in the builder. What’s happening is that the script is only populating one of these divs with the map iframe. The one being populated is the hidden one which is why you’re not seeing it on the page.

The solution would be to remove the hidden div so that there is only one on the page.

Let me know how it goes!

Hello @Rob,

This looks great but is it possible to pull the timezone based on the IP address? We want to display a specific time based on the location of the user.

Thank you.

@Rob, hi. I’m curious. Can this script be used to push the location into an hidden field? Thanks.

Userlevel 6

Hi @Adrien it sure can! You’ll just need to add a line of code to push the value of the region into a field. For example to do this with a city you could have a hidden field in the form with an ID “city” and use the following line of code:

$("#city").val(city);

Just make sure that the line of code is in the success function of the ajax call and you’ll be all set!

Hello
I tried at
https://pertodesi.audicaoactiva.pt/loja/
But no results.
Did I miss something?

Thank you

Userlevel 6

Hi @toniomorais it looks to be working for me. Here’s a screenshot: https://www.screencast.com/t/gvio3H7R8rr What are you seeing on the live page?


Could be maybe because i’m in Portugal and database from GeoIP-DB don’t have any data on Portugal?
or I have to change something in script to say that are portuguese cities?

Thank you

Userlevel 6

It is possible that GeoIP-DB doesn’t have data for Portugal. To be honest though I’d be surprised if that were the case as this they have data for much smaller countries. An easy way to test though is to go to this URL https://geoip-db.com/jsonp/ If GeoIP-DB has the data it will display the location information for where you are on the screen in json.

A potential cause could be if you have an internal firewall or proxy server set up from where you are testing from. Anything really that masks or hides your IP could cause issues when testing. Before giving up on this as a possible feature I’d recommend trying to test from different locations in the country. Perhaps you can send the link to some colleagues or friends in different places to see if they get the results?

Hope this helps a bit! Let me know if you have any luck.

Thank you for you suggestions.
This was the result:

callback({“country_code”:“PT”,“country_name”:“Portugal”,“city”:null,“postal”:null,“latitude”:38.7139,“longitude”:-9.1394,“state”:null})

It identifies the country but not the city.

Is there a way to make this work using for example maxmind ? Because I know maxmind shows the Portuguese cities.

Thank you

Userlevel 6

It’s possible that GeoIP-DB simply doesn’t have the city data for the specific IP you’re on other than the region. Although that’s pure speculation on my part. It really depends on what exists in their database which I don’t have direct access to.

It is absolutely possible to make this work with MaxMind, in fact that’s the service I originally created the workaround with. The downside (and the reason I changed it to GeoIP-DB) is that MaxMind is a paid service and you’ll need to register the domain with them before they will allow the API call to go through. If you are ok with paying for their service though I can say that it does work. Another caveat to this though is that I never tested it in Portugal so it’s possible that MaxMind will have the same issue as GeoIP-DB and not have the specific city data for Portugal.

If you do decide to go with MaxMind let me know though and I can DM you the code I originally used as that’s specific to the MaxMind API.

Hello and thank you for the support.

Yes I would like to use the code to use with MaxMind.
I know that Maxmind Have data about Portugal cities.

Thank you

Reply