Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello,
I tried to use a custom liquid block to only show content to people from the Netherlands like this:
{% if localization.country.iso_code == 'NL' %}
SOMETHING TO SHOW
{% endif %}
Most of the time this seems to work. But not allways.
I noticed some of my Belgian visitors allso see the content sometimes.
Is there another variable i can check that is more reliable? Or another solution.
Thank you,
Collin
@Cmeer Please use below code instead of the code you shared to display something only for "Netherlands" customers. Kindly let me know whether it works.
{% if localization.country.name == 'Netherlands' %}
SOMETHING TO SHOW
{% endif %}
Thank you very much!
I had to use 'Nederland' instead of 'Netherlands'. I am testing it right now. Untill now it looks good. I will let you know tomorrow.
I am checking if it works by using hotjar to see recordings of people using the website.
@Cmeer Happy to hear that my solution worked for you. Let me know for any future needs.
Unfortunately i still see some Belgian visitors who see the content. I there another variable?:)
@Cmeer It might be because if visitors from Belgium select the Netherlands through the localization option or country selector popup while visiting your website. On that time, the content added for the Netherlands will be displayed, even when the user is located in the Belgium.