What is dynamic email content?
Dynamic email content allows you to tailor your email messages to the interests of each subscriber. There are a lot of different variables that you can pull into your messages, like subscribers' geographic location and their personal information. Content that is more relevant to subscribers often translates into increased engagement in terms of opens, clicks, and conversions.
Where can I use dynamic email content?
You can make use of dynamic email content anywhere in the AWeber message editor, including the subject line.
How do I write dynamic email logic?
In order to code for dynamic email content in your messages, you would have to include the logic tags below.
{{ ... }} | Print the value of a subscriber variable | |
{% ... %} | Evaluate an expression | |
{# ... #} | Write comments in your message that are not seen by your subscribers. | |
{% raw %} | Markup within the raw tag will not be evaluated as a variable or statement. |
Operators
Operators help you display specific content if certain conditions are met. If the first condition outlined by the "if" operator is not met, then the system will look to another condition based on the "elif" operator. If neither condition is met, then the system will look to the content with the "else" operator.
If you have multiple conditions, the system will display the content based on the "and" or "or" operator.
if | Display message content IF the statement is true. | |
elif | If the first condition isn't met, evaluate another condition. | |
and | If both conditions are met, display message content. | |
or | If one of the conditions is met, display message content. | |
else | Display the following content to subscribers that did not meet any of the conditions above. |
Comparison Operators
Comparison operators work in conjunction with the operators above.
== | equal to |
!= | not equal to |
> | greater than |
>= | greater than or equal to |
< | less than |
<= | less than or equal to |
Filters
Filters help you customize the content by capitalizing specific letters, displaying fallback content when the subscriber doesn't have a value, and displaying a random option from a set of choices.
upper() | Converts each character in a string to uppercase | |
lower() | Converts each character in a string to lowercase | |
capitalize() | Capitalizes the first word in a string | |
title() | Capitalizes each word in a string | |
default() | Provides a fallback if the variable has no value assigned | Other common greeting format optimizations. |
truncate() | Returns a truncated version of a string | |
wordwrap() | Wraps a string of text to a given width. |
The string wraps when the next word doesn't fit on the line. In this example, the line width is set to only 20 characters in length. |
replace() | Return a copy of a string with all the occurances of a substring replaced with a new one. | |
first() | Returns the first item of a sequence | |
last() | Returns the last item of a sequence | |
unique() | Returns a unique set of items in a sequence | |
count() | Returns the number of items in a list | |
sum() | Returns the sum of a sequence | |
min() | Returns the smallest item in a list | |
max() | Returns the largest item in a list | |
random() | Select a random item from a set of choices | |
join() |
Returns a string of items joined by a separator. | |
select()
|
Filter a sequence to items matching the criteria provided. |
Other examples include: |
random_number() |
Returns a random number between two values. | |
round() |
Round a number to a given number of decimal places | |
now() |
Returns the current date and time. |
|
hash_md5 |
Returns an MD5 hashed value |
Date Formatting Options
Token | Example and Output | |
Year | YYYY |
The current year is 2021 |
YY |
The current year is '21 |
|
Month |
MMMM |
The month is April |
MMM |
The month is Apr |
|
MM |
The month is 04 |
|
M |
The month is 4 |
|
Day of the Year |
DDDD |
Today is day number 095 |
DDD |
Today is day number 95 |
|
Day of the Month |
DD |
Day 05 of the month. |
D |
Day 5 of the month. |
|
Do |
5th day of the month. |
|
Day of Week |
dddd |
Today is Monday. |
ddd |
Today is Mon. |
|
d |
Today is day 1 of the week. |
|
Hour |
HH |
The hour is: 04. Possible values: 00, 01, 02 ... 23, 24 |
H |
The hour is: 4. Possible values: 0, 1, 2 ... 23, 24 |
|
hh |
The hour is 04 Possible values: 01, 02, 03 ... 11, 12 |
|
h |
Possible values: 1, 2, 3 ... 11, 12 |
|
AM / PM |
A |
We will begin at 2 PM. |
a |
We will begin at 2 pm. |
|
Minute |
mm |
Possible values: 00, 01, 02 ... 58, 59 |
m |
Possible values: 0, 1, 2 ... 58, 59 | |
Second |
ss |
Possible values: 00, 01, 02 ... 58, 59 |
s |
Possible values: 0, 1, 2 ... 58, 59 | |
Date Shift |
Shift the date into the future or the past. |
The above example will print the date for "10 days ago". |
View additional documentation and examples.
For more information on dynamic email content, and the different types of variables that you can include when coding for dynamic email content, check out the articles below: