Creating Conditional Content
Personalization through Dynamic Content
Webex Campaign allows conditional logic statements for content within a message. The conditional logic can be used in SMS, MMS, and EMAIL channels. This can be around the text or even around whole segments of HTML code within an email. The conditional logic allows you to configure content to only display for specific customers, driven by values within the data.
This option is displayed for SMS, Email, and MMS channel settings. Click the Add Condition link to add the basic framework from which a user can expand on:
The conditions of the header syntax should always be in upper case. For example $(TG_MSISDN) or $TG_FIRSTNAME) etc. If you add the headers in lowercase the conditions will not be applied.
#if_X#
#elseif_X#
#else_X#
#endif_X#
Basic Conditional Logic Rules
Follow the below rules when writing conditional logic:
- The conditions if, else, and endif are mandatory in a conditional logic statement.
- The condition elseif is optional and is used if more variants of content are required to be conditionally displayed.
- The components of conditional logic for if and elseif conditions are:
◘ Condition and sequence number: #if_1.
◘ Data Header to consider values for: $(TG_<header_name>)
◘ The Operator e.g. Equals: ==
◘ Data Value to drive content: ‘P’#
The headers in conditional logic should always be written in upper case. For example, in the below condition, LOCALE is a header and it is written in upper case.
#if_1 $(EV_LOCALE) == 'gb_GB' #Hello
#elseif_1 $(EV_LOCALE) == 'bg_BG' #Здравей
#else_1#Bonasera
#endif_1#
-
Alphabetical values should be captured in single or double quote marks ‘’ / "":
#if_1 $(TG_CITY) == 'LONDON'# -
Numerical values should not be captured any quote marks:
#if_1 $(TG_VALUE) == 10# -
There should be a space between each component of the conditional logic statement.
-
The components of a conditional logic string for else and endif conditions are:
◘ Condition and sequence number: #else_1#
◘ Each condition must start and end with a hash # -
Multiple statements can be configured within the content and statements run sequentially. For example, the second conditional logic statement would begin #if_2#:
In the below scenario, if the customer had a CATEGORY value of "GOLD" and an OS value of "ANDROID", their message would read:
"This is a generic introduction message for all customers. You are a Gold customer and your phone OS is Android."
This is a generic introduction message for all customers. You are a
#if_1 $(TG_CATEGORY) == 'GOLD'#
Gold customer
#elseif_1 $(TG_CATEGORY) == 'SILVER'#
Silver customer
#else_1#
Default message customer
#endif_1#
and your phone OS is
#if_2 $(TG_OS) == 'iOS'#
iOS
#elseif_2 $(TG_OS) == 'ANDROID'#
Android
#else_2#
Default message OS
#endif_2#
Complex Conditional Logic
There are further operators on the data values you can use to run more complex conditional logic rules. The full list of available operators are:
- Equals: ==
- Does not equal: !=
- Greater than: >
- Greater than or equal to: >=
- Less than: <
- Less than or equal to: <=
You can also join statements with AND or OR conditions
- And: &&
- OR: || (double pipe symbol)
Here are some examples.
AND statement:
#if_1 $(TG_CAR_COLOR) == “RED” && $(TG_CAR_MAKE) == “FORD”#
You have a red Ford
#else_1#
#endif_1#
OR statement:
#if_1 $(TG_CAR_COLOR) == “RED” || $(TG_CAR_COLOR) == “BLUE”#
You have a red or blue car
#else_1#
#endif_1#
Combining AND/OR statements
This statement below will look at customers who have a Ford car and their insurance is up in the next 30 days or their insurance is up in the last 6 months.
#if_1 $(TG_INSURANCE_DAYS_REMAINING) <= 30 && $(TG_CAR_MAKE) == “FORD” || $(TG_INSURANCE_DAYS_REMAINING) >= 180 && $(TG_CAR_MAKE) == “FORD”#
Your Ford insurance needs updating
#else_1#
#endif_1#
Complex AND/ELSEIF Statement
This statement will look for contacts who have a ford and their insurance is up in the next 30 days, or they have a BMW and their insurance is up in the next 30 days.
#if_1 $(TG_INSURANCE_DAYS_REMAINING) <= 30 && $(TG_CAR_MAKE) == “FORD”#
Your Ford insurance needs updating
#elseif_1 $(TG_INSURANCE_DAYS_REMAINING) <= 30 && $(TG_CAR_MAKE) == “BMW”#
Your BMW insurance needs updating
#else_1#
#endif_1#
It is not possible to do nested conditional logic statements i.e. statements within statements.
Updated over 2 years ago