About the If-Then Personalization Element
The following table shows a list of If-Then personalization element components.
Personalization Element | Description |
---|---|
$(endif) |
The End-If component closes the current If-Then-Else personalization element. |
$(if [Field: FieldName]) |
TheIf component is required to start an If-Then-Else personalization element. TheIf component determines if the merge field named [FieldName] has a value. If there is a value for [FieldName], then the text between this If-Then-Else component and the next If-Then-Else component is not removed from the email. |
The following is a simple example of the use of an If-Then personalization element. If the first name is defined, then the contact's or prospect's first and last name appears. If the first name is not defined, then only the last name appears:
$(if [Field: First Name])
Dear [Field: First Name] [Field: Last Name],
$(else)
Dear Mr. or Mrs. [Field: Last Name],
$(endif)
Nesting If-Then personalization elements (placing one within another) is an acceptable practice. The following is an example of nesting these elements:
$(if [Field: First Name])
$(if [Field: Last Name])
Dear [Field: First Name] [Field: Last Name],
$(else)
Dear [Field: First Name],
$(endif)
$(elseif [Field: Last Name])
Dear Mr. or Mrs. [Field: Last Name],
$(else)
To Whom It May Concern:
$(endif)
Use of indentation indicates the nesting of one If-Then personalization element within another. Indentation is not necessary, but makes it easier to read. Also, in this example, each component is on its own line. This use of separate lines is also not necessary, but it makes reading the treatment easier.
After the Email Marketing Server makes the decision about what text or HTML to remove, the If-Then-Else personalization element components are also removed (including their trailing line breaks).