Dynamic Content

From Enterprise Help
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

"Dynamic content" allows you to customize portions or your mailing for different Segments within your Enterprise Site. For example, if you had defined a Segment called "Boston_Residents" and a Segment called "New_York_Residents", you could then compose a single message which contained content targeted to these two different Segments.


Dynamic content can be used in the context of mailings (HTML Body, Text Body, From Name, From Address, Reply To, and Subject) and in various Site Settings, but not in the online version of messages.


When creating a mailing using a template, the ability to customize content for different Segments is built into the user interface and requires no special codes. When creating a mailing without a template, however, or when using dynamic content within a mailing's From Name, From Address, Reply To, or Subject, the following syntax (case-insensitive) must be used:


To specify that a block of content should be sent to Members of a particular Segment:

##Begin(SegmentName)##
[Content]
##End(SegmentName)##

...where SegmentName refers to the unique name of the Segment, and [Content] is a placeholder for the content that should be displayed for Members in that Segment. The content can include merge codes (such as mail merge fields and predefined links), but not other dynamic content sections (i.e., dynamic content sections cannot be nested within other dynamic content sections). Dynamic content merge codes are never case-sensitive.


To specify that a block of content should be sent to Members who are NOT in a particular Segment:

##Begin(NOT SegmentName)##
[Content]
##End(NOT SegmentName)##


An alternate syntax allows for mutually exclusive dynamic content sections, as well as "default" content:

##If Not Segment("SegmentName1")##
[Content]
##Else If Not Segment("SegmentName2")##
[Content]
##Else If Segment("SegmentName3")##
[Content]
##Else##
[Content]
##End If##


...where SegmentName1, SegmentName2, and SegmentName3 are the names of different Segments, of which an unlimited number can be referenced. The keyword "Not" can optionally appear before the "Segment" keyword. The opening "If" and closing "End If" statements are required. The optional "Else" statement defines default content that should be displayed for all Members who are in none of the specified Segments. An unlimited number of "Else If" statements can be included (or none at all). In the alternate syntax, the name of the Segment must be surrounded by double-quote characters, whereas in the first syntax (the one with "Begin" and "End"), double-quote characters are optional.


Using the first syntax, we could send different content to New York and Boston residents using the following code:

##Begin(New_York_Residents)##
Go Yankees!
##End(New_York_Residents)##
##Begin(Boston_Residents)##
Go Red Sox!
##End(Boston_Residents)##


To send different content to New York residents than to everyone else, we could use the following code:

##Begin(New_York_Residents)##
Go Yankees!
##End(New_York_Residents)##
##Begin(NOT New_York_Residents)##
Go Team!
##End(NOT New_York_Residents)##

The preceding example could also be implemented using the alternate syntax:

##If Segment("New_York_Residents")##
Go Yankees!
##Else##
Go Team!
##End If##
 

Care must be taken when using multiple Segments that are not mutually exclusive. For instance, when using the following code:...

##Begin(New_York_Residents)##
Go Yankees!
##End(New_York_Residents)##
##Begin(Red_Sox_Fans)##
Go Red Sox!
##End(Red_Sox_Fans)##

...anyone who is both a New York resident AND a Red Sox fan (which is possible if these two Segments are based on different Profile Fields) will receive the following content:


Go Yankees! Go Red Sox!


If a single recipient should receive both pieces of content, then the first syntax must be used, as in the previous example. If, however, a single recipient should not receive more than a single piece of content, then you must use the alternate syntax, as in this example:

##If Segment("Red_Sox_Fans")##
Go Red Sox!
##Else If Segment("New_York_Residents")##
Go Yankees!
##End If##


In HTML, multiple consecutive whitespace characters (i.e., spaces, tabs, and hard returns) are converted into a single space character. In non-HTML contexts such as the Text Body or Subject of a mailing, however, no such whitespace conversion occurs. Therefore, when using dynamic content within non-HTML contexts, you'll need to avoid extraneous whitespace, as in the following example:

##If Segment("New_York_Residents")##Go Yankees!##Else##Go Team!##End If##