Sometimes you need to use a little customization when you’re adding merge fields to personalize your emails and landing pages. For example, say you’re adding dates to an email using merge fields. In one situation, you may want to say, “On Monday” and in another, “On October 4.”

This article shows you the formatting options available and how to add them to your merge fields. We also cover special merge fields so you can tailor your messages even further.

Table of contents

Formatting “Date” merge fields
Formatting “Date and Time” merge fields
(Advanced) Manual formatting for “Date” and “Date and Time” fields
Formatting text merge fields
Special merge fields
(Advanced) Hide the values of your merge fields


Formatting “Date” merge fields

“Date” fields can be formatted in 11 different styles and, when you add date merge fields, you can use the pop up date formatter to choose how you would like the date to display.

date formats example image

Date merge fields allow you to do “date math” by adding or subtracting days from your saved value. You can do this anytime you add a date merge field from the “Offset the date by” field on your date formatter popup.

For example, you can send your contact a happy birthday email that gives them a special offer that’s good for the entire week of their birthday. To do this, you’ll offset (add days to) your contact’s saved birth date by a week to tell them when their special offer expires.

Date formatter example image

When you add your merge field, it will look like this:

Merge fields in email example

And when you send this email to a contact whose saved birthdate is January 21, your message will look like this:

Merged data in email example


Formatting “Date and Time” merge fields

“Date and Time” fields have 14 different styles that you can choose from when you insert merge fields.

Date and time merge field formatter

Like “Date” fields, you can offset your date and time by adding or subtracting days, hours and/or minutes. Just add a negative number (-20) to subtract time and a positive number (20) to add it.

For example, you can offset your time by 20 minutes if you want to touch base with your contact before their appointment time.

Date and time formatter offset date example

When you add your merge field, it will look like this:

Merge fields in emails

For a contact who has an appointment on Wednesday at 10:30 A.M., their email will look like this:

Merged data example email


(Advanced) Manual formatting for “Date” and “Date and Time” merge fields

keyboard_arrow_downkeyboard_arrow_up

You can also create custom “Date” and “Date and Time” fields by manually formatting your merge fields using the formatting characters below. Here’s how:

  • Insert the “Date” or “Date and time” merge field you’d like to format.
  • Replace the characters contained between two “%”, [Birthday %M j, Y%+0], with a custom string you create using the characters below.

 

Formatting Character
Description
Example of what you’ll see
Day characters
d The day of the month shown in two digits with leading zeros 01 to 31
D A three-letter abbreviation for the day of the week Mon through Sun
j The day of the month without leading zeros 1 to 31
l (lowercase ‘L’) The full name of the day of the week Sunday through Saturday
N ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
S The two character English ordinal suffix for the day of the month St, nd, rd or th — This works well with “j”
w A number that represents the day of the week 0 (for Sunday) for 6 (for Saturday)
z The day of the year (starting from 0) 0 through 365
Week characters
W ISO-8601 week number of year, weeks starting on Monday Example: 42 (for the 42nd week in the year)
Month characters
F The full name of the month January through December
m The numeric representation of a month, with leading zeros 01 through 12
M A three letter abbreviation of the month Jan through Dec
n The numeric representation of a month, without leading zeros 1 through 12
t Number of days in the given month 28 through 31
Year characters
L Whether or not it’s a leap year 1 if it is a leap year, 0 otherwise.
o ISO-8601 week-numbering year.
This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.
1999 or 2003
Y A full four digit representation of a year 1999 or 2003
y A two digit representation of a year 99 or 03
Time characters
a Lowercase ante meridiem and post meridiem am or pm
A Uppercase ante meridiem and post meridiem AM or PM
B Swatch Internet time 000 through 999
g 12-hour format of an hour without leading zeros 1 to 12
G 24-hour format of an hour without leading zeros 0 through 23
h 12-hour format of an hour with leading zeros 01 through 12
H 24-hour format of an hour with leading zeros 00 through 23
i Minutes with leading zeros 00 to 59
s Seconds with leading zeros 00 through 59
u Microseconds 654321
v Milliseconds 654
Timezone characters
e Time zone identifier UTC, GMT, Atlantic/Azores
I (Capital i) Whether or not the date is in daylight saving time 1 if Daylight Saving Time, 0 otherwise.
O Difference to Greenwich time (GMT) without colon between hours and minutes +0200
P Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3) +02:00
T Time zone abbreviation EST, MDT, PST
z Time zone offset in seconds.

The offset for time zones west of UTC is always negative, and for those east of UTC is always positive.
-43200 through 50400
Full Date/Time characters
c ISO 8601 date 2004-02-12T15:19:21+00:00
r RFC 2822 formatted date Thu, 21 Dec 2000 16:01:07 +0200
U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) 1599584853

For example, if you wanted to print your contact’s birthday in the format, “Monday, Sep 7,” your merge field would look like [Birthday %l, M j%+0].

Or, if you want your contact’s birthday in the format, “7 September 2021,” your merge field would look like [Birthday %j F Y%+0].

keyboard_arrow_downkeyboard_arrow_up


Formatting Text Merge Fields

Your account saves your text values in the exact format that you import them or in the exact way your contacts typed them into forms. Site visitors often fill out forms in all caps or in all lowercase. And sometimes they use alternative capitalization that you won’t want to replicate.

But you can easily standardize the capitalization of your text merge fields! This ensures that your emails arrive in inboxes looking standardized and tidy. All you have to do is to add a modifier to your merge field.

For example, a contact may fill out your form with the first name “mary aNN,” and you can format the first name merge field in the following ways:

[First Name ##cap_lower] – Capitalize the first letter in each word and force all others to lower case.
“Mary Ann”

[First Name ##cap] – Capitalize the first letter of each word. Ignore all other letters.
“Mary ANN”

[First Name ##cap_first] – Capitalize the first letter in the first word only, and ignore all the other letters.
“Mary aNN”

[First Name ##cap_lower_first] – Capitalize the first letter of the first word and force the rest of the letters in the first word to lowercase, and ignore all other letters.
“Mary aNN”

[First Name ##lowercase] – Convert all letters to lowercase.
“mary ann”


Special Merge Fields

There are also special merge fields that do more than allow you to personalize your messages and pages with your contacts’ saved info. These special merge fields add additional functionality, such as adding a hosted email link or generating a personal coupon code.

Send Date

This merge field will show the send date of your email. You can offset that date to easily communicate about upcoming dates. For example, if you want to say an offer is valid for two days, you can add the send date merge field and offset it by two days.

send date merge field example

Hosted Email Link

This merge field lets you create a “View in browser” link. This gives your contacts an alternate way to view your email if they can’t view HTML emails or if image loading is turned off in their inbox. Paste the [Hosted_Email_Link] merge field into the URL field when creating a hyperlink.

Create a hosted link example

Coupon Codes

You can send both personal and group coupon codes to your contacts by using merge fields. You will find the coupons in the merge field dropdown in the section for “Coupon: Your Coupon’s Name.” You can add the coupon code, the date it was created, and the date the coupon expires.

coupon code merge fields

When a personal coupon code is sent to a contact, you can see it in the “coupons” tab of the contact’s record.

Note, personal coupon codes become active the day you send them to your contacts. A personal coupon code that is set to expire two days after it’s generated will expire exactly 48 hours after you send the email that delivers it.

the coupons tab

PURLs

You can insert personalized URLs (PURLs) to Ontraport hosted landing pages.

PURLs merge fields

Staff Fields

You can include information about the user who “owns” your contact’s record too. When you click the > next to the “Owner” option, you can add information from your user’s profile.

owner fields

These merge fields are really useful for sales teams. For example, you can give your contacts the name, email and phone number of the specific sales rep they work with, in case they want to follow up with any questions.

Opt-in Links

This adds a hyperlink that says “Confirm your Subscription.” If a single opted-in contact clicks this link, it will update their status to double opt-in. You can use this merge field to create your own double opt-in email.

opt-in link

Unsubscribe Link

The unsubscribe link merge field adds an unsubscribe link to an email that you send to a single contact. Your link will appear wherever you add the merge field and say, “Click Here to Unsubscribe.”

It isn’t necessary to add this to most emails because whenever you’re sending bulk email it’s added automatically. Your account adds an unsubscribe link when you send your email through:

  • Automation
  • Manual broadcasts to two or more contacts

Some users prefer to add an unsubscribe link to the top of their messages to make it easy for their contacts to find the link. If they can find it easily, it makes people less likely to get frustrated and hit the “Report Spam” button.

This merge field is also useful if you’re sending a one-off email, and you want that contact to be able to unsubscribe. It may seem counterintuitive to add an unsubscribe link you’re not required to add, but it creates a great user experience. When you allow your contacts to unsubscribe from any message, it assures them that it’s easy to leave if they want. And giving your contacts a way to do what they want helps build confidence in your business.

unsub and opt-in fields

Unsubscribe Link Raw

If you want to customize what your unsubscribe link on an email to one contact looks like, use this merge field. This provides a long, raw unsubscribe link. This option lets you select the text you would like on your unsubscribe link.

raw unsubscribe link

Paste the [unsub_link_raw] merge field into the URL field when creating a hyperlink.

create a link

Website membership details

Send out WordPress membership details like password, username, status, etc. These are commonly used to send out WordPress credentials to your contacts.

WordPress merge fields


(Advanced) Hide the values of your merge fields

If you use Ontraport’s API to send contact information to Facebook and other services that require obfuscation, then you can follow these steps to hide the value of your contacts’ information. Most commonly you’ll want to hide their email address, but you can use these steps on other merge fields as well.

  • Add the merge field you want to obfuscate using the merge field dropdown — merge field button. This ensures your field is formatted properly.
  • Add your modifiers.
    1. Use the ##H:SHA256 modifier to produce a hash value in the SHA256 format.
    2. SHA hash formatting

      1. The hash value will look like this: hashed SHA value
    3. Use the ##H:MD5 modifiers to produce a hash value in the MD5 format.
    4. MD5 formatting

      1. The hash value will look like this: MD5 hashed value