Liquid is Braze's personalization language — and it can even be used to build multi-language email templates! In this video, Jake Davis (Solution Architect) at Stitch demonstrates how to use Braze's Liquid feature to create a dynamic email template that can be personalized and sent in multiple languages. Liquid is the language Braze uses for personalization by using data from a user's profile to incorporate into messages.
Jake will walk through:
Hey, I'm Jake Davis. I'm a solution architect here at Stitch and welcome to Braze the Bar. Today, we're going to be talking about building a multi-language email with Liquid. So in this video, I'm going to walk you through importing a test data file, and then from there, we'll actually hop into a campaign and start building out an email and using Liquid, we will make it dynamic based on the language preferences of the file that I import. So let's go ahead and get started. To start here, I do have an example file, very simple. Here, you're just going to see a handful of Attributes that are needed for this import. So starting with that external ID is pretty simple. It's just a GUID that I created. We've got first name, last name, email address, and language. So there is a test record for myself and then a colleague of mine. My email will be in English, obviously, and Taylor's will be in Spanish. Flipping on over to Braze, in the user import, you can see that I've actually already uploaded this.
But let me go ahead and do that again. You can see here the two records that we are importing, and I'm just going to import these as a CSV. All right, and once those are done, I'm actually going to go and look up these individuals, just so you can see what it looks like in the account. So the first one here, let me copy that external ID. We have my record. And you can see here the language that is set is English. Now, when you are setting up language, whether it's this import or if you're setting it up through the SDK language must be in the iso 6391 formats, so it would be ‘en’ for English, ‘es’ Spanish, ‘ru’ for Russian, and so on. All of that can be found too in the braise documentation. If we look up Taylor's real quick, we will see that her test record will be in Spanish. And we are ready to actually get started with building an email and testing the liquid.
I'm going to navigate over to campaigns. In campaigns, I actually already have an email that I've started here, haven't done anything with it other than just starting on the campaign details. But here, what I'm going to do is I'm just going to select a simple drag-and-drop email. I'll do a mystery sale. And this email is one of the out-of-the-box examples, so nothing special here but what we're going to do is start walking through what the liquid would look like if I wanted to change the subject line, as well as some of that body content. Based on the standard attribute for language that I just updated. So let's jump in.
All right. So here in the subject line, I'm going to expand this box a little bit just so it's a little bit easier to work with. We have this mystery flash sale alert. What will you score? So keep with liquid here and you can use the personalization tool over here. If we have the default attribute here. You can see the money sign and then languages, what we will be using in our liquid. But I actually just prefer to type it out. I don't really use the personalization tool all that much, but let me start by, I will remove this and we'll start fresh. So like anything with liquid, we're going to start with the Bracket, the curly brace, and the percentage.
Boom. Now, what we're starting is some if-then logic. Now, this can either be longhand, where you're saying here we have the language, and I'm saying that is equal to English and from here I would type whatever I want with the English subject line. So that was Mystery Flashtail Alert. What will you score? The second one here, we can actually have it as we've got our else if, and now we're pulling language again, and I'll just copy and paste this so it's a little bit quicker.
This one we'd set for Spanish. And I've already got this translated on my second screen here. So we have the Spanish version. And then, like always, you're going to want some sort of else statement. So those that don't fall into either English or Spanish, we would want to know what subject line we would want for them. So start this up. Here we're going to be putting the else default. Again, we will repeat the mystery flash sale. And then like always with liquid, we need to end a conditional statement. So this looks a little messy because we actually already have a fallback. And in this case, I just have a Spanish version and an English version. I'm going to simplify this so that it's looking to see if your default language is Spanish, show the Spanish version else show the English versions to clean this up a little bit.
So in this case, I'm going to delete up to here, and this will actually be if language equals Spanish, use Spanish, else, English. So after we do this, we should be able to start testing right away, and to test right here in Braze, we're going to click this preview and test. You can use a random user you can also search for a user, or you can create a custom user. In this case, I'm going to search for a user and I'm going to pull up Taylor's record that we imported just before this. So when I search that record, you can see here that because that language preference is Spanish, the subject line has changed. to support that. So I'm going to go ahead and go back to those sender settings.
You can see here this liquid template that we have here is what we'll use actually to change the rest of the email as well. So I actually have some of these already on my second screen here, but I'm going to pull over the content and this is where it can get a little bit messy. So if you are using one of the out-of-the-box emails it can get a little crowded. In this case, this is a header and we have a subheader. You'll see as I start adding in the liquid, it gets a little bit messy. So sometimes it helps to actually develop some of that liquid outside of the account and then paste it in. So we'll start with that. So this first one here is for a mystery flash sale. The size is 58. What I'm going to do is just paste this in and then within the account here, I will highlight the actual content that I want to be large and to match what that template was. So I'll make those 58. I have three secret offers here. Same thing. I will just highlight this. This is size 22. Paste that in, highlight the relevant copy, and change it back to what you need it to be. And the last one here is to reveal your deal.
This one should be good to go. So we're going to test this again, hop over to preview and test. Now preview and test, you can see that this is still using Taylor's record, which has Spanish set as the language. So we've got the subject line we're looking for. We have the header and the subheader that we're looking for, as well as that reveal button. So everything seems to be working there. If I go back and just select a random user, and get a random user, this will pull up anybody in the account. These are all fake records that have been auto-generated. And in this case, all of these people that are coming through are having the default language, which is English. And in this case, there isn't a language even set. These individuals are just falling back based on the liquid that we set up.
So I'm going to actually pull up my record one more time here. Search user, and here you can see my record has the language set up for English. So we can see how that works. Flipping back one more time to content. The basics of what we're going through here are setting up your conditional statement. And again, this is assuming you have a base knowledge. Of the liquid language. But what we're doing is looking for anyone where language equals ES, show that version. Else, default back to the English version.