Skip to main content
KeviSunshine
Expert Problem Solver III
Expert Problem Solver III
October 27, 2022
Solved

Conditional subject lines using template language–is it possible?

  • October 27, 2022
  • 1 reply
  • 563 views

Hi all,

Within a metric-based flow, I’d like to add a conditional subject line to an email.

However, I’m running into two problems...

First, I can’t write a subject line that exceeds 255 characters. Even though the subject would be resolved to way fewer characters, the character counter is including the template tags as characters.

Second, is this even possible? Can I use conditional template tags like {% if event.field %} in a subject line?

Here is my conditional.

{% if event.flag1 and event.flag2 %}✅ You're good!{% elif event.flag1 and not event.flag2 %}❌ You're maybe not so good!{% elif not event.flag1 and event.flag2 %}❌ You're definitely not good.{% elif not event.flag1 and not event.flag2 %}❌ You're not good at all. Definitely.{% endif %}

Thank you!

Kevin.

    This topic has been closed for replies.
    Best answer by stephen.trumble

    Hey @KeviSunshine 

    Thanks for asking another great question! 

    You can typically use any template tag or variable in the subject line that you would otherwise use in the body of the email. However, even though your tags would resolve to less than 255 characters, your code still has to fit within the 255 character limit and all on the same line. 

    Hope this helps!

    1 reply

    stephen.trumble
    Klaviyo Alum
    October 27, 2022

    Hey @KeviSunshine 

    Thanks for asking another great question! 

    You can typically use any template tag or variable in the subject line that you would otherwise use in the body of the email. However, even though your tags would resolve to less than 255 characters, your code still has to fit within the 255 character limit and all on the same line. 

    Hope this helps!

    -Stephen