Understanding @if/@else conditional logic

Modified on Tue, 5 May at 6:27 PM

Understanding @if/@else conditional logic

Conditional logic lets your email and SMS templates show or hide content based on the lead's actual data. Use it to personalize messages, add fallbacks, and build smart dynamic communications without writing code.

TL;DR

Wrap content in @if(%field%){ ... }@endif. Add @else{ ... } for a fallback. Compare with ==, !=, ~=, <, >. Combine checks with && (AND) or || (OR) — but not both together. Press CTRL+K / CMD+K in any template field to find placeholders instantly.

4 things to know

1

Basic @if — show content only if a field has a value

@if(%assigned_person_name%){
  Your consultant is: %assigned_person_name%
}@endif

Note: 0, false, off, nej, no, n all evaluate as false even though they are non-empty.

2

@if / @else — show different content per scenario

@if(%assigned_person_name%){
  Your consultant is: %assigned_person_name%
}@else{
  You do not have a personal consultant yet.
}@endif
3

Comparison operators — compare values precisely

== equal  ·  != not equal  ·  ~= contains (case-insensitive)  ·  < <= > >=

@if(%lead_postal_code% >= 6000){ For Jutland support call: +45 12 34 12 34 }@endif

@if(%lead_company% ~= A/S){ Company name contains "A/S" }@endif
4

Logical operators — combine multiple conditions

AND: @if(%field_a% == X && %field_b% == Y){ ... }@endif
OR:  @if(%field_a% == X || %field_a% == Y){ ... }@endif

Important: Parentheses are NOT supported. || is evaluated before &&. Don't mix both in the same expression.

Read more

Nested @if statements

@if(%assigned_person_name%){
  Your consultant is: %assigned_person_name%

  @if(%assigned_person_phone%){
    Call %assigned_person_firstname% at: %assigned_person_phone%
  }@endif

}@else{
  You do not have a personal consultant yet.
}@endif

Date comparison

@if(%lead_created_at% < @str2datetime[-2 weeks]){
  Lead is more than 2 weeks old
}@endif

Finding placeholders with CTRL+K / CMD+K

Press CTRL+K (Windows) or CMD+K (Mac) in any template field to open the placeholder search. Search by natural words: "lead name", "event date", "address", "signature". This is the fastest way to find the exact placeholder and avoid typos.

Best practices

  • Use the slug value (not the label) when comparing select fields
  • Always add @else for fallback content in customer-facing templates
  • Use the editor's built-in examples section for for-loops, variables, and JSON patterns
  • Test conditions with real leads before activating

Common searches

@if conditional logic • @else fallback template • contains operator ~= • conditional email • show hide content template

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article