Forum Discussion
Liquid Country Help Please!
I am trying to create a piece of dynamic content that shows for multiple countries.
I have created this code which worked a few weeks ago, but now isn't working:
{% if {{${country}}} == 'ID' and 'AE' and 'TR' and 'EG' and 'SA' and 'PK' and 'BD' and 'MY' and 'NG' %}
I have tried with or and that doesn't work either!
Any help would be massively appreciated, thank you.
- StuartPractitioner III
I've started using Case/When more and more for things like this. I think it's cleaner than if/elsif. Eg:
{% assign country = {{${country}}} %}
{% case country %}
{% when "GB" %}
Copy for GB
{% when "FR", "AR" %}
Copy for FR or AE
{% when "TR" %}
Copy for TR
{% else %}
Copy for everyone else
{% endcase %} - roebucklActive Member
Thanks both! We got it sorted with this:
{% if {{${country}}} == 'ID' or {{${country}}} == 'AE' or {{${country}}} == 'TR' or {{${country}}} == 'EG' or {{${country}}} == 'SA' or {{${country}}} == 'PK' or {{${country}}} == 'BD' or {{${country}}} == 'MY' or {{${country}}} == 'NG' %}
- DavidOStrategist II
Hi roebuckl
chris is spot on, as you need to let Braze know you want to check the attribute for each term e.g. does country = AE and does country == TR and so on.
Reading the liquid however, you might need to test this but I feel like you will need to use OR for your use case.
{% if {{${country}}} == 'ID' and {{${country}}} == 'AE' and {{${country}}} == 'TR' ....
This liquid currently reads as 'for user X, does their country attribute equal 'ID' and 'AE' and 'TR'... and it cannot be all three at once.
Happy to be corrected but I feel you might need this if you are wanting to select different countries:
{% if {{${country}}} == 'ID' or {{${country}}} == 'AE' or {{${country}}} == 'TR' ....
'for user X, does their country attribute equal 'ID' or 'AE' or 'TR'...
If you are wanting the content to go to bunch of different countries that you select with liquid
- laasyam3Active Member
We made some helpful videos about liquid! Here is a link: Mastering Conditional Logic in Braze with Liquid
- chrisActive Member II
Try including the country attribute in each statement, like:
{% if {{${country}}} == 'ID' and {{${country}}} == 'AE' and {{${country}}} == 'TR' ....
Related Content
- 6 months ago