Conditional Visibility based on Geolocation

Hi all, has anyone tried to show/hide a div based on the visitor’s location?

For example, to show div A if the person is in country A, and show div B if the person is in any other country?

I found a few code samples online but as always, it’s best to ask the WF community and see if anyone is familiar with something that worksin WF.

Thanks!


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

HI @Yaco,

You can go to https://webflow.com/website/Geolocation-Setup-for-Webflow?s=geojs to see how you can pull user location info, but to change the behavior of a DIV container you need to use JS.

See this for reference:

Let me know if you need any help!

1 Like

Thank you @Carlos_Ruiz_Del_Vizo ! This looks very helpful.

Do you , or anyone looing in, think this is possible using webflow?

@webdev @PixelGeek , you guys are often in the know.

I’m not very familiar with coding JS, but I found an example on hiding a div based on location here: javascript - How to show or hide element based on Geo ip - Stack Overflow

Thanks all

@Yaco, this requires a little bit of more work from a person who knows JS. You can send the project and let me see what you are trying to do for a more accurate response.

1 Like

Hi @Yaco –– I’m investigating the same thing. Curious, did you find a good solution or were you able to integrate JS to do this? Would be curious to hear about your experience.

1 Like

I keep gettin CORS errors when I try to call external geolocation apis. Anyone figure out any work arounds? I have tried 3 different GEO IP apis and they all are blocked by CORS

I do too, is there are workaround here?