How to Build a Personalized Email Using Liquid — Thread the Needle with Braze

Using cookie-cutter generalized messaging no longer works — customers today expect tailored and relevant content that addresses their specific needs and interests. For a modern marketer, personalized messaging is the key to building long-lasting and strong customer relationships.

In this video, Taylor Smith, Solutions Architect at Stitch, walks through how to create an email using Liquid, Braze’s open-source template language developed by Shopify and written in Ruby - used to template data from a user’s profile into messages, with personalized first names, custom attributes and arrays. 

Transcript:

 Hi, I'm Taylor Smith. I'm a Solution Architect here at Stitch, and I'm excited to show you how to build a personalized email using Liquid and Braze with our Threading the Needle with Braze video series.  Before I dive in, I want to provide a quick overview of Liquid for those who aren't familiar with it.

Liquid is a templating language used in Braze to deliver personalized experiences to customers across messaging channels. This includes email, SMS push, in-app messages, browser messages, and content cards. It was created by Shopify and is written in Ruby.  In this video, I'll cover some basic and advanced use cases for personalizing an email using Liquid.

Personalization is a really powerful tool to leverage to create more engaging content for your customers. However, it should be handled with care as too much personalization could be interpreted negatively by your audience. So always take the time to develop a strategy for a campaign and layer in dynamic content and personalization to complement it in a way that makes sense.

Okay, so let's get into the Braze dashboard and go through some examples for this demo. I'm going to be working from email templates within Braze, so let me just pull up my screen. Perfect, so here in Braze and the left side navigation, I'm going to navigate to templates and then into email templates.

So to just cover the content in a more succinct way, I've already created some examples here, but just so you know where I started. I'm working from this ‘Welcome To’ template that is out of the box for Braze, so if you want to replicate this on your own, this is the one that I am working with. So I'm going to click into this Braze demo email template that I've started and then I'm going to click into edit email body.

So as a first example, just want to go through a basic way of using personalization to pull in first name into your campaign. This is a really common use case. First, I'll show you using the preview and test feature within Braze — how you can look for a specific user and see how the email renders for that user.

I'm going to grab my email that I want to select. So currently, since I've not specified a user to preview with right now, there's no first name displaying. And in this first example, I wanted to show you just how when you search a user as well, and I don't have a first name or last name in on this user profile.

So that same experience is visible here. No first name is being displayed. I'm going to switch this to Taylor@stitch.cx. And now you can see I have first name, last name on this user profile. So Taylor is rendering here on the right. One thing when using personalization and for a simple use case like this, it is really critical to specify a fallback scenario just so that way, if the data isn't available on the user profile, there's still something in place of it that's being created to create a strong user experience.

So for the previous user I was showing, we want to add a default value in that case. So I'm going to go back to content. What I'm going to highlight is the personalization tool that is available in Braze. This is a really user friendly tool. It's a great way to pull in personalization easily into your email campaign.

And there's just lots of different personalization types that you can leverage with this tool as well. But in this case, I'm going to keep it selected as default attributes. But if I click this drop down, there's a lot more options here as well for what you could use with this tool. First name is a standard attribute. I'm going to keep it as that, and then select first name. Currently the liquid snippet is exactly how it is displayed in my email. This first name is a part of that ‘Welcome To’ template that I started with, so it was already here. But with the personalization tool, what I can do is add friend here.

You may have noticed that the liquid snippet here changed a little bit to bring in that default value, so that is now showing there as first name, but then assigning the default a friend. So I'm just going to copy this and then paste it into my email. It's going to change the rendering a bit. So I'm just going to update that and give it that nice blue color it had before.

Perfect. So now if I preview again with that user that did not have a first name, what I'll see, well, it's going to pull up this Taylor one first. So you can still see my first name pulling in there, but let me change the user to Taylor@threadtheneedle. And now you can see the fallback experience of friend.

Again, this is a really good practice to do whenever you're using personalization is to create that default experience.  One quick note as well— when using personalization, there are filters that you can apply as well that allow you to modify the output of numbers, strings, variables, and other objects that you're using with Liquid.

So, as a quick example, I want to now modify this first name personalization and have it appear as welcome here and be all uppercase, so I'm going to add upcase to this Liquid snippet and preview it again. And now it's mirroring welcome and being all uppercase and it would do the same if I search the other user as well.

And, uh, adding uppercase to my first name here. I have the documentation pulled up from Braze on filters. There's a lot of different options available here for how you can modify personalization strings. So I would definitely suggest taking a look and seeing what is available.

 The next use case of personalization that I want to get into is a little bit more complex. It's going to be a demonstration of how you can use conditional logic to create specific dynamic content based on a customer's attributes. So for this example, I have my Taylor@threadtheneedle email pulled up. The custom attribute I'm going to use to create this conditional logic is the loyalty program attribute for this user. It's set to false, but on Taylor@stitch.cx, it is set to true. So we'll be able to show those two different experiences with this example. So I have the liquid pulled up on my other screen, so I'm just going to copy it.

 And actually I want to paste it here. So, loyalty program is what I used as the example, just because this campaign that I used, that's the example just from Braze. It's welcoming someone to their brand, letting them know, thanks for signing up. This is what we'll be sending. This is the type of content and subject matter you'll be getting.

So in this welcome message, let's say that they had also signed up for the loyalty program. With this use case, we could start by saying if custom attribute loyalty program is true. If they did also sign up for that upon signing up for email, then let's remind them of the benefits that they get by having done that by enrolling in the loyalty program.

And in the else experience, we could add one more nudge to the user to have them join the loyalty program. And just so we're completing this, I'm going to add a link in here just to display that whole experience. Give it a link to make it a little bit more official, so yes. So what's happening here?

The conditional logic, if the custom attribute loyalty program is true, show this message that's showing them the benefits they have at the loyalty program. If not, hey let's nudge them one more time, join the club in our loyalty program here. So again, Taylor@threadtheneedle is the one that has loyalty programs set to false.

So I forget which one is previewed right now. It's just Taylor Smith, so this one is set to true. So we are expecting to see this message here, so that is good. Let me grab that other email, paste it.

Oh, this is a good example. I think I have an extra space in there. I do. So that's why it's not changing. There we go. So now you can see that fallback message, join the club, enroll in our loyalty program here. So again, that's just an example of conditional logic before I just showed a really basic use case of pulling in first name and how you can apply filters.

Conditional logic is a bit more advanced, but it's a great way to make your email content dynamic based on user attributes and custom attributes. You can use this conditional logic around all kinds of content within email builds, so text is an example. You can also do it around images or content blocks as an example.

The last thing I want to show is actually in a different email template. So let me go back out to templates. Scroll up when you go back. Let me select this final one. The last example I'm going to show is how you can use an array within an email as well. An example of how this could be used, for instance, is for net shop. Let's say they have transactional email and they want to display from an array that is passing to Braze all of the different products that were purchased within that transaction.

So I'm going to click on here. It's a bit small on the screen, but with an array what we need to do is create a for loop to pull in all the items that are contained within that array and display them in the email. So what I'm doing here is at the top. Apologies if it's a bit small, but I'm creating this new variable fruits, and then I'm assigning the custom attribute array attribute as that variable fruit. So I don't have that user pulled up, but let me switch it. So array attribute is here. What's represented there is banana and apple. So again, this is where we're pulling this custom attribute from this user profile to create this display of the array within the email. So this loop is starting by specifying that variable fruit, and then for each item in the variable fruits, we're going to do X. And what is specified here is we're printing the index of the loop, as well as the index of the array, and then the item from the array as well, and then just creating some formatting.

That way it displays in a nice order. So I'm going to click preview and then search the user that has the array. There we go. Now you can see the index and the item that are displayed there from the array. So again, this is a welcome campaign we started with. It's just a template from Braze but if this were a transactional message, there could be a use case where you want to display all the products that were included in a transaction. Using an array like this is a way that that could be accomplished.

Thank you so much for watching. I'll leave you with one final reminder about Liquid. Always, always review and test your emails that have Liquid before you deploy them just to make sure. Across the different experiences, if there's different variants within an audience, you want to check each one to make sure it's all working as expected, so definitely don't forget to do that. Thank you so much for watching and be sure to check out our other videos on our website. Thanks so much. Bye.

You might also like...