Dynamic tags allow you to hand-code conditional personalization in your email design. In early 2020, we launched an easier way to add conditional content to your emails and blocks. Learn more about Conditions
What is a dynamic tag?
Dynamic tags allow you to personalize your email design with conditional statements. This is a valuable tool if you need to send one version of your email to one group and an alternate version to another group.
if/then statements
Dynamic tags can be as simple as dropping in a first name with an alternate, or they can involve more conditional statements. WordFly dynamic tags follow traditional if/then statements that use operators.
Tag component | Definition | Example |
IF | This is the minimum condition. If conditions can be used alone or at the top of a chain. When a new condition is dropped into an email, it defaults to an if statement. | {{if(##DataField## == A) then (A statement) endif}} |
ELSE IF | Optional. You can chain together as many as needed. Else If conditions can only appear in the middle or end of chain. | {{if(##DataField## == A) then (A statement) endif elseif(##DataField## == B) then (B statement) endelseif else(Statement if no conditions are met) endelse}} |
ELSE | Optional. Use this as a fallback when needed. Else conditions can only appear at the end of chain | {{if(##DataField## == A) then (A statement) endif elseif(##DataField## == B) then (B statement) endelseif else(Statement if no conditions are met) endelse}} |
END | End will end a minimum condition/statement (endif) to allow another (endelseif) to begin; or it will end (endelse) the conditional tag. | {{if(##DataField## == A) then (A statement) endif elseif(##DataField## == B) then (B statement) endelseif else(Statement if no conditions are met) endelse}} |
Operators
Dynamic tags use operators to meet conditions and key off statements. The operator tells WordFly what connection to make with the data field in the if part of the conditional statement.
Example: {{if(##DataField## == A) then (A statement) endif}}
In this example, WordFly is looking for DataField to be equal to A in order for the minimum condition to be met to display the A statement. Any subscribers that have data equal to this DataField will see the A statement.
Note: Only certain operators are available depending on the data field selected. For example, with a preference data field, only less than or greater than operators are available.
Available operators:
- == equal to
- != does not equal
- contains
- does not contain
- > greater than
- >= greater than or equal to
- < less than
- <= less than or equal to
What to expect using dynamic tags:
- {{ }} Double curly braces in front and behind the statement define the code as an if/then statement.
- ## ## Double pound signs in front and behind the data field name define which field should be displayed.
- Punctuation and capitalization must match your data field name exactly. If your data field has a space in it, make sure your tag has a space, too.
- || Double pipes function as the else statement for simple tags. Example: {{##First Name## || Friend}}.
- ( ) Statements are enclosed in parentheses.
- Dynamic tags cannot be nested within existing dynamic tags.
You can set up complex dynamic tags that key off specific conditions to show the right content to specific subscribers.
Create a basic dynamic tag
A basic dynamic tag is a data field plus an alternate, if the data is missing. For example, if First Name is missing in the list data the dynamic tag would insert something else like 'Friend' instead. You can create a basic dynamic tag under Subscribers > Dynamic tags. You can also create one inside the editor when you are adding a Data Field to any text block.
A basic dynamic tag looks like this:
{{##Data Field## || Alternate Text }}
{{##First Name## || Friend }}
To create a basic dynamic tag based on a data field
1. Go to Subscribers > Dynamic Tags
2. Click Create a new tag
3. Click 'Show basic options'
4. Start customizing your basic Dynamic Tag...
- Select Data Field from the first dropdown
- Give the tag a brief name.
- Select the data field you’d like to display.
- Enter some alternate text in the If Missing field.
5. Click Save to add the tag to your library
Create an advanced dynamic tag (with if/then statements)
Advanced options allow you to create multiple if/then logic statements and alternates for your dynamic tag. You can also specify the default behavior if none of the statements are true. Advanced tags are helpful when you need to send one email to multiple groups of subscribers. The dynamic tag will ensure each subscriber receives the correct data based on their data.
An advanced dynamic tag looks something like this:
{{if(##Data Field## == Data) then (Insert a statement for this condition) endif else(If none of the above if conditions are met, use this instead) endelse}}
{{if(##Continent## == North America) then (November 11, 2017) endif else(11 November, 2017) endelse}}
This tag says: If Continent is equal to North America, then write "November 11, 2017"; otherwise, write "11 November, 2017".
1. Go to Subscribers > Dynamic Tags
2. Click Create a new tag
3. Start customizing your advanced Dynamic Tag...
- Select Data Field from the first dropdown
- Give the tag a brief name.
- For the first section, enter your initial if/then criteria. Select your 'if' properties by selecting a data field, then an operator, enter criteria, after this enter in some text for your 'then'. Now you have your initial if/then statement created.
- Do the same for the 'Alternate' section. Here you are defining an alternate if/then if the first set of criteria is not met.
- Select 'Add another alternate' if you wish to add more.
- Finally, in the 'Default' section enter text to display when all statements are not met.
4. Click Save to add the tag to your library
To edit dynamic tags
You can manually edit any dynamic tags in any email designs across any email campaigns. Dynamic tags in the library can not be edited from Subscribers > Dynamic tags.
To delete dynamic tags
1. Go to Subscribers > Dynamic tags.
2. In the Dynamic Tags section check the boxes to the right of the tags you'd like to delete.
3. Select Delete from the Actions dropdown.
Tips for dynamic tags
Pay attention to your data fields in dynamic tags
Dynamic tags always use data fields to key off the if/then logic. Data fields can also be used in the then statement to further personalize the content being delivered. In order for the data field to work properly it must be added exactly as it is in Subscribers > Data Fields. Data fields are case sensitive. Your casing must match.
Example of dynamic tag with a data field providing statement data:
{{if(##Subscriber## == 2013) then (We look forward to seeing you at ##Next Show##.) endif else() endelse}}
HTML formatting in dynamic tags
WordFly supports valid HTML within dynamic tags. In the editor, highlight text in the dynamic tag statement and apply your styles - italics, bold, headline etc - as you normally would apply styles to text. Make sure to read through all of the best practices listed in this article to understand the boundaries.
Example of dynamic tag with bold formatting applied to the statement portion:
{{if(##Subscriber## == 2022) then (We look forward to seeing you at ##Next Show##.) endif else() endelse}}
You can also use a data field to pull HTML into dynamic tag statements. All the same best practices apply. Learn more about HTML and data fields.
Example of a dynamic tag with a data field providing HTML to fill in the content:
{{if(##Subscriber## == 2022) then (We look forward to seeing you at ##Next Show##.) endif else(##Non Subscriber upsell language##) endelse}}
Links in dynamic tags
Use valid HTML to add a link in your dynamic tag.
Do this
{{if(##Continent## == Australia) then (<a href="https://wordflyevents.webex.com/wordflyevents/onstage/g.php?t=1">Register</a>) endif else( ) endelse}}
Don’t do this
{{if(##Continent## == Australia) then (<"https://wordflyevents.webex.com/wordflyevents/onstage/g.php?t=1">Register) endif else( ) endelse}}
Spaces can sometimes be interpreted as "%20" which might break the tag.
Do this
{{if(##City## == Seattle) then (http://media.wordfly.com/mctommerson/City/Seattle_neighborhood_party.png) endif else(We will let you know when a Neighborhood party is coming to your city) endelse}}
Don’t do this
{{if(##City## == Seattle) then (http://media.wordfly.com/mctommerson/City/Seattle%20neighborhood%20party.png) endif else(We will let you know when a Neighborhood party is coming to your city) endelse}}
Tip: In your email campaign, use Testing > Email Checklist to check links in dynamic tags and dynamic links. If there's an error, the link won't track.
Remove any breaking special characters
Symbols "&" and "()" and “!” can break your dynamic tag. Try using dashes instead of parentheses and periods instead of exclamation points.
Do this
{{if(##First Name## == ) then (Hello,) endif else(##First Name##) endelse}}
Don’t do this
{{if(##First Name## == ) then (Hello!) endif else(##First Name##) endelse}}
Adjust spacing between conditions
When paragraph tags surround conditional content there is default spacing in the paragraph style that will add space to each condition.
To remove this space from the paragraph style:
1. From your block, click on STYLES.
2. Select the paragraph element.
3. Select Adjust spacing.
4. Remove any margin that is set. There is default margin bottom on all paragraphs.
Making dynamic tags longer
You can manually edit tags to make them longer since our tool only allows four alternates. Follow the pattern of the tag to extend it.
Basic tag example:
{{if(##DataField## == A) then (A statement) endif elseif(##DataField## == B) then (B statement) endelseif elseif(##DataField## == C) then (C Statement) endelseif elseif(##DataField## == D) then (D Statement) endelseif else(Statement if no conditions are met) endelse}}
Here’s how the tag works:
- The tag begins with If to start the condition and uses then to provide the first statement if that condition is met.
- To key off the second condition, the tag uses endif elseif, which ends the last statement and brings in the second if/then condition+statement.
- To key off the third condition, the tag uses endelseif elseif, which ends the second if/then combination and from here you can build on the tag.
- Continue extending the tag after this one by placing a space after the last statement and pasting in endelseif elseif(##DataField## == X) then (X Statement).
- Once you have extended the tag to your desired length you will use endelseif else(Statement if no conditions are met) endelse as the last portion of the dynamic tag. This ends the conditions and gives one last statement to use if none of the conditions are met.
Extended tag example:
{{if(##DataField## == A) then (A statement) endif elseif(##DataField## == B) then (B statement) endelseif elseif(##DataField## == C) then (C Statement) endelseif elseif(##DataField## == D) then (D Statement) endelseif elseif(##DataField## == X) then (X Statement) endelseif elseif(##DataField## == Y) then (Y Statement) endelseif elseif(##DataField## == Z) then (Z Statement) endelseif else(Statement if no conditions are met) endelse}}
Editing existing tags
You can manually edit Dynamic Tags without making a new tag. You can do this directly in your email design. You can also have the tag in separate email designs and edit them completely differently without having one change the other.
Confirm the dynamic tag in the text version of your email, too
Dynamic tags will work in your text version but should always be tested.