Forum Discussion

deblock1376's avatar
deblock1376
Practitioner II
2 years ago

Dynamic subject in drop-and-drag template

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. 

 

  • 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!

3 Replies

  • DavidO's avatar
    DavidO
    Strategist II

    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.

    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. 😊




  • 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!

    • deblock1376's avatar
      deblock1376
      Practitioner II

      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.