Using Oracle Email Marketing On Demand > Designing the Email Message Body >
Using Conditional Content in Email Marketing
Conditional content provides the ability to present relevant information to individual email recipients without having to create multiple messages. There are two ways to generate conditional content within an email:
- Named Blocks personalization
- If-Then-Else personalization
NOTE: Conditional content and merge fields are available in both HTML and Text format emails.
Named Blocks Personalization
Named blocks determine whether to insert a block of text or HTML into an outgoing email by comparing one string to another:
- If the two strings are identical, the block is inserted.
- If the two strings are not identical, the block is not inserted.
NOTE: The string comparison is case sensitive.
Table 6 lists the components of the Named Blocks personalization element.
Table 6. Named Blocks Personalization Components
Personalization Component
|
Description
|
$(DefineBlock "MatchString")
|
Starts a block of text or HTML that is inserted in place of an Insert Block component when MatchString is identical to the MatchString of the Insert Block component.
|
$(EndBlock)
|
Ends a block of text or HTML that was started with the Define Block component.
|
$(InsertBlock "MatchString")
|
A block of text or HTML is inserted at the location of this component when MatchString is identical to the MatchString of a Define Block component.
|
The following is an example of a Named Blocks personalization element:
<P>You live in $(InsertBlock "${Account.Country}").</P> $(DefineBlock "USA") <B>the United States</B> $(EndBlock)
$(DefineBlock "India") <B>India</B> $(EndBlock)
In this example, if USA is entered in the Country field of the account record, the following sentence appears:
You live in the United States.
NOTE: If a given recipient has no associated value for a named block variable listed in the InsertBlock MatchString component, then nothing is inserted into the message for that block.
To insert named blocks
- Place the cursor in the location where you want the Insert Block.
- Create the Insert Block statement:
- In the Categories list, select Insert Block.
- In the Objects list, select the record the field comes from: Account, Campaign, or Contact.
- In the Items list, select the field in the record.
- Click Insert.
- Create a Define Block component:
- In the Categories list, select Create Block.
A $(DefineBlock "") and $(EndBlock) statement appear in the text.
- Type a field value within the quotation marks of the $(DefineBlock "") statement. This is the value that drives the content displayed in the block.
- Type the text that you want to insert into the email between the $(DefineBlock "") and $(EndBlock) tags.
- Repeat Step 4 until you have added all the Define Block components that you want.
If-Then-Else Personalization
If-Then-Else personalization provides the ability to insert or remove text within your email content, based on whether a Merge field value is defined. The merge field is defined if it contains a value or, for numeric merge fields, if the value is not 0 (zero).
- If the merge field is defined, the text remains in the outgoing email.
- If the merge field is not defined, the text is removed from the outgoing email.
Table 7 lists components of the If-Then-Else personalization element.
Table 7. If-Then-Else Personalization Components
Personalization Component
|
Description
|
$(if {Record.FieldName})
|
The If component is used to start an If-Then-Else personalization element. It determines whether the merge field named [FieldName] has a value. If there is a value for [FieldName], the text between this If-Then-Else component and the next If-Then-Else component is not removed from the email.
|
$(elseif {Record.FieldName})
|
The Else-If component is the same as the If component, except that it is used within the If-Then-Else personalization element, not at its beginning.
|
$(else)
|
The Else component is used after a $(if) or $(elseif) component. If the preceding $(if) or $(elseif) component removes the preceding block of text or HTML from the email, the $(else) component's block of text or HTML is included in the email. If the preceding $(if) or $(elseif) component does not remove its block of text or HTML, the $(else) component's block of text or HTML is not included in the email.
|
$(endif)
|
The End-If component closes the If-Then-Else personalization element.
|
The following is an example of an If-Then-Else personalization element.
$(if ${Contact.First Name}) Dear ${Contact.First Name}${Contact.Last Name}, $(else) Dear Mr. or Ms. ${Contact.Last Name}, $(endif)
If the Contact.First Name field is defined, the email begins with Dear First Name Last Name.
If the Contact.First Name field is not defined, the email begins with Dear Mr. or Ms. Last Name.
You can use If-Then-Else statements similarly to Block statements, by including operators such as Equal to, Starts with, or Contains. You can select these operators from a list when you generate If or If-Else statements. Unlike Blocks, this is how you insert conditional content where the variable is true or not true.
For example, to customize the email with a condition for accounts in the state of California, you use the statement:
$(if ${Account.Bill to State} == "CA") Join us all month long for special events and workshops held in each of our California locations. $(else) Join us all month long for weekly online workshops and special offers at www.mycompany.com/events. $(endif)
You can also nest If-Then-Else statements, placing one within another.
NOTE: The components of personalization elements must be placed in the correct locations in the text. Any incorrect placement causes an error.
To insert if-then statements
- Place the cursor in the location where you want the If-Then statement.
- Create the If or Elseif statement:
- In the Categories list, select either If or Elseif.
- In the Objects list, select the record the field comes from: Account, Campaign, or Contact.
- In the Items list, select the field in the record.
- In the Operators list, select the operator.
- In the text box, enter the value that the field is compared with.
- Click Insert.
- Below the If or Elseif statement, enter the text that appears if the condition in the statement is satisfied.
- At the end of the entire If-Then-Else statement, enter $(endif).
|