cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic subject in drop-and-drag template

deblock1376
Practitioner II

How can I create a dynamic subject line in a drop-and-drag template? Use case: We send a daily list of headlines. I'd like the subject to be the first headline. 

I have the loops set up in the email body, but it doesn't work to add the title loop to the subject line. 

 

1 ACCEPTED SOLUTION

AllanHeo
Strategist II

One thing to keep in mind is that the subject line and body are kept separate in Braze. So you probably have to include your loop inside the subject line and template the very first line in the subject line itself. 

If you have the loop in the body, but you're trying to template the result of that loop in the subject line, that won't work. 

Hope this helps!

View solution in original post

3 REPLIES 3

DavidO
Strategist

Hi @deblock1376 

I'm assuming you are referring to using liquid templating language in the subject line to display the relevant heading. It should work exactly the same way as liquid in the email body. I'm a bit confused when you say loops.

For example I just tested having the first name added in the subject line for a Drag and Drop email with this liquid and it worked fine.

DavidO_0-1689641751868.png

DavidO_1-1689641795465.png

Here is the actual code you can cut and paste in the subject line to test:

 

 

{% if {{${first_name}}} %}Hello {{${first_name}}} 
{% else %}Hello
{% endif %}

 

 

Some good liquid references in case you need to check the terminology:
Liquid template language (shopify.github.io)
Liquid Filters (braze.com)
Liquid Use Case Library (braze.com)

If this doesn't work let us know and we'll keep looking at it. 😊




AllanHeo
Strategist II

One thing to keep in mind is that the subject line and body are kept separate in Braze. So you probably have to include your loop inside the subject line and template the very first line in the subject line itself. 

If you have the loop in the body, but you're trying to template the result of that loop in the subject line, that won't work. 

Hope this helps!

Thank you! This is what I did.

I actually created a subject line content block:

{% connected_content {feed} :save topstories %}{{topstories[0][0].title}}

And then just added the content block to the template's subject line.