BRAZE LIQUID — Liquid Filters — Liquid For Technical Marketers

BRAZE LIQUID — Liquid Filters — Liquid For Technical Marketers

🗣️ WATCH FULL YOUTUBE VIDEO HERE 🗣

https://youtu.be/bteJrqTNb7w

What’s up everyone, my name is Allan, Founder and Consultant at For Now Marketing, and welcome to LIQUID FOR TECHNICAL MARKETERS!

Liquid Filters are one of the 3 types of Liquid code that we mentioned in a previous video. Filters take your Liquid variable and change the output, allowing us Marketers to be flexible in our personalization.

Watch the full video to learn more about Liquid Filters!

Liquid Filters List

Before we get started, let’s first quickly scroll down this long list of Filters provided in the Liquid basic documentation. There are tons of useful filters, some that I use very, very regularly, and some that comes in handy occasionally.

Please take some time to look through every single one of these Filters, to expose yourself to all the different capabilities of Liquid Filters. You might be surprised to find some solutions to issues you’ve been having in your Marketing Personalization.

One thing to note is that Braze supports most of these Filters, but not all. Be sure to cross reference between this Shopify doc and the Braze Doc called Filters, which is this page right here.

Parameters

Before we start talking about Filters, let’s briefly talk about a term called Parameters.

Generally speaking, Parameters are variables that are part of a function, and the function, or the Filter in our case, relies on the parameter to determine the output.

Filters with No Parameters

A handful of Filters don’t require any Parameters, meaning all you need to do is insert the pipeline character and the Filter, and the Filter just goes to work. For example:

{% assign name = “allan” %}

{{ name | upcase }}

upcaseis an example of a Filter that doesn’t require a parameter. the upcase Filter just takes the variable and turns every character into uppercase.

By the way, one quick thing to note here is that Filters can also be used directly inside the Assign Tag. So here’s a different way to write this Liquid snippet that would have the exact same result:

{% assign name = “allan” | upcase %}

{{ name }}

In this situation, the upcase Filter is used directly inside the assign tag, so I don’t need to re-include the Filter when we reference the name variable. And sometimes, it makes more sense to use the Filters directly inside the Assign Tag.

One Parameter

This time, let’s look at a Filter that does have a required parameter. All the Math Filters require a parameter, so let’s look at those.

For example, let’s start with the plus Filter which does exactly what it says: it adds a number to our variable. What would happen if we used our plus Filter without any parameters, like the example below?

{% assign number = 7 %}

{{ number | plus }}

What are we adding to our variable number? How much should we add? Liquid has no idea, because we didn’t use the Parameter that the plus Filter requires. The plus Filter will look for a number along with the Filter that will be added to our variable. So here’s a correct example:

{% assign number = 7 %}

{{ number | plus: 2 }}

To add a Parameter to our Filter, you add the colon, followed by the value for that Parameter. By the way, to throw in another key term, specific parameter values are called Arguments. So in our case, the 2 would be our Argument, which follows the Parameter requirement for the plus Filter.

Multiple Parameters

Let’s look at another example that requires two parameters, the replace Filter, which is a very useful one that has saved my life so many times.

The replace filter Replaces every occurrence of the first argument in a string with the second argument.

The replace Filter requires two parameters: the Filter will look for any instances of the first argument, and when it finds that exact match, the Filter will REPLACE the first argument with the second argument.

Here’s an example:

{% assign liquid_status = “Liquid Level: Beginner” %}

Here we have a String called liquid_status that will render “Liquid Level: Beginner”.

However, you watched all the Liquid For Technical Marketers videos, and now your Liquid Level is at Proficient.

Using the replace Filter, we can look for any occurrence of the String “Beginner” and replace it with the String “Proficient”. Here’s what that looks like.

{{ liquid_status | replace: “Beginner”, “Proficient” }}

By the way, the order of the parameters are crucial, so be sure to read the Liquid documentation to confirm how each Filter and their parameters work!

For replace, we find the first parameter, and replace it with the second parameter. If we were to accidentally switch up the two parameters here, nothing would happen because there’s no instance of the String “Proficient” inside our variable liquid_status.

Mix & Match

For our last example, let’s go back to our Math Filters to see an example where we mix & match multiple Filters. Yes, we can use as many Filters as we want, and the subsequent Filters simply follow the same syntax of pipeline characters and colons.

Remember those magic math operations from elementary school? Let’s try one using Liquid. First, here’s the math operation steps.

  1. Think of a number.
  2. Multiply it by 3.
  3. Add 6.
  4. Divide this number by 3.
  5. Subtract the number from Step 1 from the answer in Step 4.

And here’s how that would look like in a single Liquid line using multiple Filters. First, let’s think of a number.

{% assign my_number = 7 %}

Now, time for our magic:

{{ my_number | times: 3 | plus: 6 | divided_by: 3 | minus: my_number }}

This is an example of using multiple Filters within a single line.

Also, one final thing to note is that I actually used a variable, in fact, the exact same variable my_number, for the argument for the last Filter minus. So you certainly can use other variables as Filter arguments, and you can even use the same variable as the one you’re starting with.

By the way, the answer to this magic math operation is always 2, no matter what you choose as your starting number. Try it yourself!

Thank You!

That’s it for today! Thank you for watching, and see you next time!

allan@fornowmarketing.com

fornowmarketing.com

Previous
Previous

BRAZE LIQUID — Date Variable & ISO 8601 — Liquid For Technical Marketers

Next
Next

BRAZE LIQUID — Assign & Capture — Liquid For Technical Marketers