BRAZE LIQUID: Logical Operators (and/or)— Liquid For Technical Marketers
These next 5 minutes could save you 15% or more on your Braze Segmentation mistakes.
If you want to learn more about and/or logical operators, this is the video for you!
Back in my high school computer science teaching days, we spent a whole chapter on and/or logical operators.
Here is the super condensed version, featuring Drake.
Braze Liquid Operators Documentation: https://shopify.github.io/liquid/basics/operators/
🗣️ WATCH FULL YOUTUBE VIDEO HERE 🗣
What’s up everyone, my name is Allan, Founder and Consultant at For Now Marketing, and welcome to LIQUID FOR TECHNICAL MARKETERS!
If your goal is to improve your Liquid coding skills, then please:
- like this video
- subscribe to our channel
- watch this video all the way to the end
- and keep an eye out for more videos in the future.
Today, we’re going to talk about and/or logical operators. There’s only two logical operators in Liquid, “and” and “or”, and we’ll talk about how they work inside a Liquid Conditional. Also, we will come back to this super informative Drake image later in the video.
Let’s get started.

Liquid Conditionals Sneak Peek
Previously, we talked about Liquid Comparison Operators, and today, we’re talking about Logical Operators. Similar to Comparison Operators, Logical Operators are only relevant inside Liquid Conditionals, so we will see Liquid Conditionals in today’s video also.
As a reminder: for all examples today, if the Liquid Conditional statement is logically true, then the message between the “if tag” and “endif tag” will render.
Conditional Statements
Before we dive into both of the Logical Operators, let’s review Liquid Conditional Statements and Comparison Operators as these two topics will also be relevant in today’s video.
We went over 6 Comparison Operators, in the previous video: equals, does not equal, greater than, less than, greater than equal to, and less than equal to.
Here's what a Conditional Statement, that uses a Comparison Operator, looks like in the context of liquid.
So we have our variable called status, which is equal to the value VIP, and we have a liquid conditional that checks if status is equal to VIP.
“Status == VIP” is our conditional statement that uses the equal comparison operator.
Now where logical operators come in to play is if we have multiple conditional statements that we want to check in our liquid conditional statement.
For example, what if we have a message for someone who is both a VIP status and has been a member for more than five years? Or how about either one of those?
That's where logical operators come to play.
Let's take a look at the first logical operator, and.
and
When using the “and” logical operator, both conditional statements must be true for the logical operator to return the value of true. To clarify, only two conditional statements can be compared with a single logical operator, for both “and” and “or”.
So let's go ahead and create another variable that represents the number of years of membership like we mentioned previously.
And we're going to add to our existing if-statement by adding the “and” logical operator and adding a conditional statement that checks if membership years is greater than five.
Once again, the “and” that operator only returns true when both conditional statements are true.
In our case, both status equals VIP and membership years is greater than 5, so our if statement would return true, and when we click the test button, we should see the message, “Thank you for being a VIP member!”
However, even when one of the conditional statements return false, the “and” logical operator will return false. For the “and” logical operator to return true, it's an all or nothing basis.
So let's see what happens when we change membership years to 3.
We see no message render because our if statement was not true overall.
Going back to our Drake image, it looks like the top image represents false, and the bottom image represents true.
Notice that for our “and” example, we have both a false and a true image. And together, they lead to the false image, which makes sense, because once again, “and” logical operator only returns true when both conditional statements are true.
Let's move onto the “or” logical operator.
or
Or is our second logical operator. For or to return true, only one of the two conditional statements must be a true statement. So, even if one of the conditional state statements are false, if the other one is true, then the whole or logic will return true.
Let's change our liquid example from “and” to “or” and see what happens. If we click test, we see that the message renders again because our status is still equal to VIP, even though our membership years is not greater than 5.
In this case, if a user satisfies either one of these conditions, they would see this message.
However, if both the conditional statements are false, then the “or” logical operator will result in false as well. So, by changing the status to something else, this message will not render.
And lastly, going back to our Drake example, even though under the or column, there's both a true and false image, noticed that this results in a true image. That's how “or” logical operators work.
Common Mistake
Let's wrap up this video by addressing one very common mistake we see when using logical operators. We see this common mistake often when the variable that we’re comparing is the same for both conditional statements.
Here is an example.
Let’s say we have a special message for users whose membership_years is greater than equal to 5 and less than equal to 7.
We may incorrectly write our liquid like this:
{% if membership_years >= 5 and <= 7 %}
One thing to note is that whenever we’re using logical operators, both conditional statements have to be full conditional statements, meaning, there's a variable, a comparison operator, and a value that were comparing to.
In our example, it's like we're comparing these two conditional statements
- membership_years >= 5
- <= 7
And the second statement is obviously only a partial conditional statement, which doesn't make sense. Liquid will see this and think what is less than or equal to seven?
To fix this, make sure to write the full conditional statement for both statements, even though, our incorrectly written statement makes sense for human intuition.
Here's what the correct version looks like:
{% if membership_years >= 5 and membership_years <= 7 %}
Thank You!
That’s it for today! For simplicity, we did not talk about having 3 or more conditional statements in this video.
If you're using the same logical operator for all three or more, the same logic from this video should apply.
If you're mixing and matching different logical operators for three or more conditional statements, be sure to read the liquid documentation for more details. We will also keep this topic in mind for a future video!
Thank you for watching, and see you next time!
fornowmarketing.com