You are here: Message Personalization and Scripting > Conditional Content Commands > ifcondition

ifcondition [any/all]

 

ifcondition all

Use the "ifcondition all" command when you want certain content to be inserted when allof a particular set of conditions are true (i.e., condition1 and condition2 and condition3...).  

 

The "ifcondition all" syntax is:

 

%%
ifcondition all
tablename.fieldname1 value1
tablename.fieldname2 value2
...
tablename.fieldnamex valuex
"content-if-true"
"content-if-false"
%%

 

Here, for each individual recipient, the command evaluates whether every field is equal to the listed value. The first condition, for example, looks in table tablename1 for the field fieldname1. If the value in that field is equal to value1, then the command concludes that condition is true. There is no limit on the number of conditions you can have.

 

If allthe listed conditions are true, the command prints content-if-true. If even one of the conditions is not true, the command prints content-if-false.

 

Example 1 (ifcondition all)

 

You want to tell people in Springfield, Illinois, about your new store there. Since there are many Springfields across the US, you need to specify which one using the state field. You store information on city and state of residence in the members_ table.

 

%%
ifcondition all
members_.city springfield
members_.state IL
"Come see our new Springfield store!"
"We're opening new stores all the time!"
%%

 

Residents of Springfield, Illinois, will see:

 

Come see our new Springfield store!

 

Residents of Springfield, Oregon, or Chicago, Illinois, or any other place, will see:

 

We're opening new stores all the time!

 

 

Example 2 (ifcondition all)

 

You want to tell only women with white cats living in Springfield, Illinois, about your new store there. You also store information on gender, pet ownership, and pet color in the members_ table. Simply add more conditions:

 

%%
ifcondition all
members_.city springfield
members_.state IL
members_.gender F
members_.pettype cat
members_.petcolor white
"Come see our new Springfield store!"
"We're opening new stores all the time!"
%%

 

Female, white-cat-owning residents of Springfield, Illinois, will see:

 

Come see our new Springfield store!

 

The rest of us will see:

 

We're opening new stores all the time!

 

ifcondition any

Use the "ifcondition any" command when you want certain content to be inserted when anyof a particular set of conditions are true (i.e., condition1 or condition2 or condition3...).  

 

The "ifcondition any" syntax is:

 

%%
ifcondition any
tablename.fieldname1 value1
tablename.fieldname2 value2
...
tablename.fieldnamex valuex
"content-if-true"
"content-if-false"
%%

 

Here, for each individual recipient, the command evaluates whether every field is equal to the listed value. The first condition, for example, looks in table tablename1 for the field fieldname1. If the value in that field is equal to value1, then the command concludes that condition is true. There is no limit on the number of conditions you can have.

 

If any the listed conditions are true, the command prints <content-if-true>. If all of the conditions are false, the command prints <content-if-false>.

 

Example 3 (ifconditional any)

 

You want to tell people living in the states of California, Washington, and Oregon that they will now be covered by a new salesperson.

 

%%
ifcondition any
members_.state CA
members_.state WA
members_.state OR
"Your new account rep is Sheila!"
"
%%

 

Recipients who live either in California, Washington or Oregon will see:

 

Your new account rep is Sheila!

 

If a recipient doesn't live in any of these states, they'll see nothing at all. You could of course specify that something else be printed if none of the conditions are met.

 

Example 4 (combining conditional content commands)

 

Say you send a regular direct marketing HTML email to all your customers. If they own a dog, their email will contain a special promo for dog food. If they own a cat, they receive a promo for cat food, and similarly for hamsters. If they own any combination of the above, the email will contain promos relevant to each of their animals. If they do not have any of the animals above, only the basic message is sent.  

 

All pet ownership data is kept in a series of true/false fields that allow customers to select multiple pet interests.

 

%%
ifcondition any
members_.hasdog T
members_.hascat T
members_.hashamster T
" <p>
 We're having a special promotion on:<p>
 <ul>
 [%%iffield members_.hasdog T < <li>Dog food! > <>%%]
 [%%iffield members_.hascat T < <li>Cat food! > <>%%]
 [%%iffield members_.hashamster T < <li>Hamster food! > <>%%]
 </ul>
 <p> "

"
%%

 

The first part determines whether they have an appropriate pet at all; the second part provides a bulleted, HTML list of appropriate promotions. You could also use such conditions to turn large, formatted blocks of text or table rows on and off.