How to Create Dynamic Content Blocks with Drag-and-Drop Tools — Thread the Needle with Braze

For marketers, staying efficient and consistent is crucial, and Braze’s Content Blocks help marketers do just that by centralizing messaging content. Marketers can easily reuse content across channels — email, push notifications, in-app messages, and more — by eliminating the need for tedious duplication and ensuring a unified brand experience. Marketers can easily deliver a captivating customer experience with relevant, timely, and consistent messaging. 

In this episode of Thread the Needle, Czar Dela Cruz, Solution Architect at Stitch, walks through how to create dynamic content blocks while still using drag & drop tools in Braze's email builder, including: 

  • Personalizing your email using Liquid 
  • Tailoring hero images using HTML Content Blocks 
  • Creating dynamic recommendations based on user preference


Transcript:

Hello, hello, and welcome to season two of Thread the Needle with Braze. My name is Czarnest Dela Cruz, and I am a technical producer over at Stitch. In this episode, we'll demonstrate how to create Content Blocks while using the drag-and-drop tools in Braze's email builder. We'll learn how to personalize greetings, show location based content, and recommend adventures dynamically.

Let's jump in.

For today's example, we'll be taking a look at email campaigns targeting customers who have provided information regarding future travel and activity interests. So I started off with this pre made template, Celebration. Just to save some time, I went ahead and added some of my own content into this email.

Let's open that up and take a look.

So, you'll see your standard header. You'll notice that there's four hero images here, each specified for location. So, this one's Spain, a Spain hero, Greece hero image, Italy hero image, and a general, generic hero image. We have some copy, additional hotel offers here in the body, and then some, adventures you might like for customers here.

The first thing that we'll do is we'll go ahead and we'll personalize the greeting a little bit. It just says hi right now, so we'll go ahead and insert some Liquid code to personalize the greeting, with the recipient's first name. So, Liquid is a templating language used in Braze to create a dynamic and personalized content for your messaging campaigns.

So we'll go ahead and do that by clicking on this plus personalization. First name is a default attribute. So we'll be able to go ahead and select that and then pull the Liquid snippet from here.

And then to add a default, you'll go ahead and just insert a straight bracket. I'm not sure what those are called, but you'll go and insert one of those in there. Type default, colon and then valued, let's go with 'valued customer'. So if we go ahead and preview and test this, what you will see, uh, let's go ahead and preview and test.

We'll go ahead and pull a random user, and we have Bill.

Don't forget your spaces, but we have Bill here, who's provided his name. So we say, 'Hi Bill.' Let's see if we can find a user that's not. And, here. So we have a user that didn't provide their name, and we have the default as 'Valued Customer.'

The next thing that we're going to do is we're going to take care of these hero images. We're going to tailor these towards specific customers. And I have a specific set of customers that have provided where they've wanted to go, their preferences on each of these countries here. One thing I do want to call out is that this solution works very well with the drag and drop.

As you can see, this email is entirely built out of the drag and drop template in Braze, but it intertwines that with the use of some HTML content blocks here. So what we'll do is we'll go ahead and drop an HTML content block. in that row. And then what we'll do is go ahead and add some conditional statements here.

So, if you're not familiar, a conditional statement is used to basically display certain blocks, if specified conditions are met. This is useful for customizing content based on variables, user data, or other dynamic inputs. Let's go ahead and expand this a little, and insert this Liquid here that we can talk about a little bit more.

So, because some of the data that we've collected, we have vacation interests. Our customers here at your company have provided that information that they've desired to go to specified locations. That is the custom attribute here, and we're just assigning it to the country. So for this first hero image, we'll go ahead and insert additional Liquid. So if that country equals Spain, it will display this hero image here. We're going to go ahead and add an additional row and do the same for Greece.

Let's add that HTML block, expand. If your country is Greece, it'll display this next image.

We'll do the same for Italy. Drop that in. Let's go and drop an HTML block in there. Expand this, and add that else if statement for Italy. And then we'll do the same for a default HTML block, expand that, add that else. So if none of those options are available for that customer, it'll just default to this. And then we have to close, close off this if statement. We'll do so by adding another HTML block and then pasting in our end if.

So if we go ahead and go to preview and test.

This individual does not have any information or has not provided their destination or their country of interest, and so they get the default. But if we search for some of the other users that we have here, here we have Jim. And if we go down, we can see that his custom attributes, his vacation interest is Spain. And so he has the Barcelona hero image. If we look at another user, here we have Dwight, whose vacation interest is Greece, and we have the Greece hero image.

And then just to take a look at one more user, Michael gets the Italy image, and you can guess that his vacation interest is also Italy. So that's a conditional statement there for those hero images.

And then finally, what we want to do next is we'll go ahead and add dynamic adventure recommendations based on the customer interests. So the way to do that is a loop. A loop is a way to repeat a block of code multiple times. In Liquid, a loop helps you display a list of items dynamically. Think of it as telling the system do this action for every time this item is listed.

So we'll go ahead and scroll down here and you can see that we have adventures that you like, currently, each of these are static. These are typed in, added in, but we'll go ahead and do is go ahead and add in some of our own code here. So we'll go, let's go ahead and add another row.

And as you guessed it, we're going to add another HTML block here. And then let's see for this HTML block, we are going to add a little bit more than what we did before because it is a for loop. It is a little bit more advanced. We are going to target this first.

So we're going to take a look at each line of code step by step here. and basically this is looking at that adventure preference custom attribute. And we're going to say that's product string.

Taking a look at here, what we're doing here is basically this line is splitting the product string into an array of individual product IDs using comma space as a separator.

Here, we're beginning our loop. This is the line that starts the loop, and goes through each product ID, and the product's array. In here, we're looking up a catalog, so basically this line is fetching the catalog items from the data source called Dynamic Demo Adventure using the current product ID to retrieve the details.

And then this line here is just ensuring that there are items in the catalog that can be returned. And so what we're going to do is actually, we're going to go ahead and remove these items here. We're going to go ahead and do is add some code here for the image.

We're going to go ahead and add adventure name, adventure price. See if we can bring that back up to 14 pixels and then change the color back to blue, yeah, let's do that. We'll leave the description as is. But for that hero image, let's go ahead and make sure that image is back in there, and then we'll go ahead and also add adventure URL. Don't worry about the URL image. That seems to be, it should be updating appropriately. For some reason, it just defaults there to what it was before, but it should work.

Here we'll go ahead and add that URL again. But basically what this is doing is saying that, Hey, you know, items is just basically a variable representing the collection in the array. Zero is just accessing that first item in the array. And then, this adventure URL is basically just the attribute in that first array.

So what we should see is, basically our catalog here full of information, uh, regarding the adventure types. So as you noticed earlier, I was inputting adventure name, adventure image, adventure price, and adventure URL. You can also place other components, other pieces of content here for the email, depending on what you'd like.

So as you can see, we have adventure alt text, adventure type, anything that could be useful in the campaign. Then what we need to do is go ahead and close this off for this to actually work. So let's go ahead and add another row here. We'll add HTML block. and then we're going to go ahead and end that loop. We're going to end that if statement, going to end that loop, end if, end for, and then let's go to preview and tests.

So, remember we do have Michael here. Michael is interested in going to Italy. His preferences are 1,3, and 5. So if we look at the catalog, we have 1, which is Hiking Adventure 1. 3, Hiking Adventure 3, and then 5, which is Diving Adventure 2. So, if we scroll down, we should see those. But for some reason those aren't populating.

Let me see here. Let's go ahead and drop that image back in. And then jump over to Preview and Test.

There we go. So we have a Diving Adventure 2, Hiking Adventure 3, Hiking Adventure 1, $50, $150, $350, those are booked in. And then as you can see, your company at Dive. com, Diving 2. If we go ahead and jump into another user, let's see what Dwight wanted to go to Greece. Dwight's activities of interest were 2,4, and 6. So 2,4, and 6 is Hiking Adventure 2, Diving Adventure 1, Diving Adventure 3. Scroll down. Hiking Adventure 2, Diving Adventure 1, Diving Adventure 3. As you can see, again, populated all of those.

And then just one more here. Let's see what Jim wanted to check out. Jim did 1, 8, 9. And so we have a Hiking Adventure 1 for Jim, and then 2 Fishing Adventures, which should match the catalog. Fishing Adventure, Fishing Adventure, and then Hiking Adventure.

And that's it. We've successfully created dynamic email, with personalized greetings, location based content, and adventure recommendations, all using Braze's drag and drop email builder. Make sure to preview and test your email to ensure everything displays correctly for different users.

Thank you for watching this demo. If this demo was helpful for you, go and hit and like, and subscribe to learn more about Braze. Til next time. 

You might also like...