Streaming live at 10am (PST)

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:
https://www.w3schools.com/jsref/met_element_setattribute.asp

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: https://stackoverflow.com/questions/30173809/how-to-show-or-hide-element-based-on-geo-ip

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