Solutions keyboard_arrow_down keyboard_arrow_up
Our Solutions
Ontraport's solutions work together to give you everything you need to run your business in one centralized, easy-to-use platform.
Resources keyboard_arrow_down keyboard_arrow_up
Resources
Find free content on the latest marketing strategies, using Ontraport in your business, and finding the right software.
Visit the blog
University Pricing Chat
clear
Merge field formatting
Last updated on: July 5, 2023

Sometimes you need to use a little customization when you’re adding merge fields to personalize your emails and 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.”

With merge field modifiers, you can change how you display your data without editing the content of your fields.

In this article, you’ll learn how to use merge field modifiers to customize how your saved content looks in emails, pages and other assets. This makes it easier for you to communicate your message effectively in different contexts.


Table of contents

Populating merge fields
Date and Time merge fields
Manual formatting for Date and Date and Time fields
Color merge field modifier
Text merge fields
Capitalization merge field modifiers
Other text modifiers
Checkbox merge field modifier
Dropdown and list selection merge field modifier
File merge field modifiers
URL merge fields
Price merge fields
Image merge field modifier
General merge fields
Encrypt merged data

Populating merge fields

For your merge fields to display and pull values from visitors’ contact records, your page needs to be able to identify who is visiting.

There are a few ways Ontraport can tell your pages who is visiting; check out this article to learn how.

Date and Date and Time modifiers

Back to top

##time_ago – Display the relative date and time formatting.

  • Example: [Page//Last reply ##time_ago]
  • Result: 3 hours ago

Manual formatting for Date and Date and Time merge fields

Back to top

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:

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


Formatting CharacterDescriptionExample of what you’ll see

Day characters
dThe day of the month shown in two digits with leading zeros01 to 31
DA three-letter abbreviation for the day of the weekMon through Sun
jThe day of the month without leading zeros1 to 31
l (lowercase ‘L’)The full name of the day of the weekSunday through Saturday
NISO-8601 numeric representation of the day of the week1 (for Monday) through 7 (for Sunday)
SThe two character English ordinal suffix for the day of the monthSt, nd, rd or th — This works well with “j”
wA number that represents the day of the week0 (for Sunday) for 6 (for Saturday)
zThe day of the year (starting from 0)0 through 365

Week characters
WISO-8601 week number of year, weeks starting on MondayExample: 42 (for the 42nd week in the year)

Month characters
FThe full name of the monthJanuary through December
mThe numeric representation of a month, with leading zeros01 through 12
MA three letter abbreviation of the monthJan through Dec
nThe numeric representation of a month, without leading zeros1 through 12
tNumber of days in the given month28 through 31

Year characters
LWhether or not it’s a leap year1 if it is a leap year, 0 otherwise.
oISO-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
YA full four digit representation of a year1999 or 2003
yA two digit representation of a year99 or 03

Time characters
aLowercase ante meridiem and post meridiemam or pm
AUppercase ante meridiem and post meridiemAM or PM
BSwatch Internet time000 through 999
g12-hour format of an hour without leading zeros1 to 12
G24-hour format of an hour without leading zeros0 through 23
h12-hour format of an hour with leading zeros01 through 12
H24-hour format of an hour with leading zeros00 through 23
iMinutes with leading zeros00 to 59
sSeconds with leading zeros00 through 59
uMicroseconds654321
vMilliseconds654

Timezone characters
eTime zone identifierUTC, GMT, Atlantic/Azores
I (Capital i)Whether or not the date is in daylight saving time1 if Daylight Saving Time, 0 otherwise.
ODifference to Greenwich time (GMT) without colon between hours and minutes+0200
PDifference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3)+02:00
TTime zone abbreviationEST, MDT, PST
zTime 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
cISO 8601 date2004-02-12T15:19:21+00:00
rRFC 2822 formatted dateThu, 21 Dec 2000 16:01:07 +0200
USeconds 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 [Page//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 [Page//Birthday %j F Y%+0].

Color merge field modifier

Back to top

##color_field_hex – Display the hex code of your color field’s value.

  • Example: [Page//Visitor//Rank ##color_field_hex]
  • Result: #FFD700

If you are an advanced user, you may want to dynamically access the hex code of a value in your color field.

For example, when you use inline CSS to customize the color of your text, your code would normally look like this:

<p style=”color:#FF0000;”></p>

But you can replace the hex code in this styling tag with a formatted merge field. This will allow the color of your text to change dynamically.

Here’s how:

  • Use the merge field dropdown button to insert a merge field for your color field.
  • Add “##color_field_hex” to the end of your merge field.
    • For example, if your field is named “Color field,” your merge field should look like this: [Page//Color field ##color_field_hex]

This is really helpful if you are adding custom code to your dynamic pages and want to pull in the hex values of your color fields. For example, this code will use a “Rank” field’s color on the text displayed.

When your visitors land on your page, the text will change colors depending on the value saved in the “Rank” color field.

Bernard, who has the “Gold” rank, will see this message:

And Paige will see this version:

Text merge fields

Back to top

Capitalization merge field modifiers

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

When you use merge fields, your page or email will display text exactly how it’s saved in your field. When text from a form fill out contains unconventional capitalization, you might want to fix that. Or, if you’re building apps, you can use different capitalization in different contexts.

But you can easily standardize the capitalization of your text merge fields! All you have to do is to add a modifier to your merge field. These merge field modifiers ensure your content looks precisely how you like.

For example, a contact may fill out your form with the first name “ELEANOR.” You can use merge field modifiers to ensure her first name displays as “Eleanor” in your email.

Here are all of the capitalization merge field modifiers you can use and how they’ll change your text:

##cap_lower – Capitalize the first letter in each word and force all others to lower case.

  • Example value: ELEANOR
  • Example merge field modifier: [page//first Name ##cap_lower]
  • Result: Eleanor

##cap – Capitalize the first letter of each word. Ignore all other letters.

  • Example value: digital marketing manager
  • Example: [Page//Title ##cap]
  • Result: Digital Marketing Manager

##cap_first – Capitalize the first letter in the first word only, and ignore all the other letters.

  • Example value: increasing brand awareness
  • Example: [Page//Marketing Goals ##cap_first]
  • Result: Increasing brand awareness

##cap_lower_first – Capitalize the first letter of the first word and force the rest of the letters in the first word to lowercase. Ignore all other letters.

  • Example value: iNCREASING brand awareness
  • Example: [page//marketing Goals ##cap_lower_first]
  • Result: Increasing brand awareness

##lowercase – Convert all letters to lowercase.

  • Example value: iNCREASING brand awareness
  • Example: [page//marketing goals ##lowercase]
  • Result: increasing brand awareness

##uppercase – Convert all letters to uppercase.

  • Example value: Limited time offer
  • Example: [PAGE//HEADLINE ##UPPERCASE]
  • Result: LIMITED TIME OFFER

Other text modifiers

Back to top

##plaintext – Will print the plain text — text that is not formatted — version of your rich text fields.

“ • Exercise examples and videos
  • Tools for getting and staying active
  • Adding physical activity to your life”

  • For: Rich text fields
  • Example: [Page//Related resources ##plaintext]
  • Example field value:
  • Result: “Exercise examples and videosTools for getting and staying activeAdding physical activity to your life”

##jsonescape – Encodes strings the way the json_encode php function would format them. This will manage escaping quotes within quotes to ensure your json is properly formatted.

  • For: Text, long text and rich text fields
  • Example: [Page\/\/JSON long text ##jsonescape]
  • Example field value: {"widget": { "debug": "on", "window": { "title": "Sample Widget", "name": "main_window", "width": 500, "height": 500 }, "image": { "src": "Images/Sun.png", "name": "sun1", "hOffset": 250, "vOffset": 250, "alignment": "center" }, "text": { "data": "Click Here", "size": 36, "style": "bold", "name": "text1", "hOffset": 250, "vOffset": 100, "alignment": "center", "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" } }}
  • Result: {\"widget\": {\n \"debug\": \"on\",\n \"window\": {\n \"title\": \"Sample Widget\",\n \"name\": \"main_window\",\n \"width\": 500,\n \"height\": 500\n },\n \"image\": { \n \"src\": \"Images\/Sun.png\",\n \"name\": \"sun1\",\n \"hOffset\": 250,\n \"vOffset\": 250,\n \"alignment\": \"center\"\n },\n \"text\": {\n \"data\": \"Click Here\",\n \"size\": 36,\n \"style\": \"bold\",\n \"name\": \"text1\",\n \"hOffset\": 250,\n \"vOffset\": 100,\n \"alignment\": \"center\",\n \"onMouseUp\": \"sun1.opacity = (sun1.opacity \/ 100) * 90;\"\n }\n}}

##ellipsis(NUMBER_OF_CHARACTERS) – Allows you to show snippets of text instead of all the text in a field.

  • For: Text, long text, rich text and address fields
  • Example: [Page//Blog post description ##ellipsis(150)]
  • Example field value: “Your team members are often interacting with your customers, and their own satisfaction and passion for their work always shows through. So keeping your team members happy is just as important as delivering on your promise to your customers.”
  • Result: “Your team members are often interacting with your customers, and their own satisfaction and passion for their work always shows through. So keeping yo…”

Checkbox merge field modifier

Back to top

##checkediftrue – Adds “true” if your checkbox is checked and “false” if it is unchecked.

  • Example: false
  • Example field value: ☑
  • Result: true

Dropdown and list selection merge field modifier

Back to top

##filter_val:ID_OF_FIELD_OPTION – Adds “true” if the number you add to the end of your modifier matches the ID of the selected dropdown or list selection option. And it adds “false” if the number does not match.

  • Example: false
  • Example field value: Sales qualified lead (ID = 487)
  • Result: true

You can find the IDs of your list selection and dropdown field options using Ontraport Live API documentation.

  • Use the GET request for your objects field editor.



##drop_down_id – Shows the ID of your dropdown field’s value. You’ll use this modifier in API requests to specify specific dropdown values by their ID.

  • Example: [Page//Level of expertise dropdown ##drop_down_id]
  • Example field value: Some experience (ID = 503)
  • Result: 503

File merge field modifiers

##link – Adds a raw download link anyone can access

  • Example: [Page//Freebie PDF ##link]
  • Example file value: Freebie.pdf
  • Result: https://pawsitivevibes.ontraport.com/s/dl?token=WzE3MTEzNCwwLCIxNzExMzRfNjQ5YTA0ZWVlZGIxYzQuNjE4MDA3ODBfT250cmFwb3J0LUV4cGVydHMucGRmIiwiT250cmFwb3J0LUV4cGVydHMucGRmIiwiMCIsIjg1ZGM4ZDIyOGU5NTMwY2Y5MTAwNTVhNzFmOTk0YmM1Il0%3D

##link:ONTRAPORT_MEMBERSHIP_SITE_NAME – Adds a raw download link that any member of your site can access

##name – Adds the name of your file

  • Example:
  • Example field value: Freebie.pdf
  • Result: Freebie.pdf

##linked_name – Adds a download link hyperlinked to the name of your file anyone can access

  • Example:
  • Example field value: Freebie.pdf
  • Result: Freebie.pdf


##linked_name:ONTRAPORT_MEMBERSHIP_SITE_NAME – Adds a download link hyperlinked to the name of your file any member of your site can access

URL merge field modifiers

Back to top

##schemaless – Removes http:// or https:// from the beginning of URLs.

  • Example: [Page//Website ##schemaless]
  • Example field value: https://ontraport.com
  • Result: ontraport.com

##video_id – When your URL field contains a video link, this merge field will display only the ID of the video.

  • Example: [Page//Youtube Video URL ##video_id]
  • Example field value: https://www.youtube.com/watch?v=h-GciA15qas
  • Result: h-GciA15qas

##video_hash – When your URL field contains a Vimeo video URL, this modifier pulls out the video_hash from the url when it’s in the format “player.vimeo.com/[Page//Video_id]?h=[Page//Video_hash]” or “vimeo.com/[Page//Video_id]/[Page//Video_hash]”.

  • Example: [Page//Vimeo Video URL ##video_hash]
  • Example field value: https://vimeo.com/320369670/eced817cc0
  • Result: eced817cc0

Price merge field modifier

Back to top

##blank_if_price_zero – If the price of your product is set at zero, this modifier will prevent the price from displaying.

  • Example: [Page//Block//Price ##blank_if_price_zero]
  • Example field value: $0.00
  • Result: The result will be blank

(No Currency Symbol) – Remove the currency symbol from in front of your price merge fields.

  • Example: [Budget (No Currency Symbol)]
  • Example field value: $20,000
  • Result: 20,000

Image merge field modifier

Back to top

##link – Display the hosted URL of your image. This allows you to insert images into custom code using image tags.

  • Example:
  • Example HTML image tag: <img src="" alt="[Page//First Name]’s profile image" style="width: 25%;"/>
  • Result:
    Sarah's profile image

General merge field modifiers

Back to top

##hash_if_blank – If the field’s value is blank, this modifier will only display a hash mark (#).

  • For: All fields except numeric and price
  • Example: [Page//Event date ##hash_if_blank]
  • Example field value: No value
  • Result: #

##find_and_replace('ORIGINAL VALUE' , 'REPLACEMENT VALUE') – Find and replace text inside your merge fields. This is helpful if you have fields that contain characters or symbols you’d like to change.

  • For: All fields
  • Example: [Page//Website-##find_and_replace('-','-')]
  • Example field value: https://slurpeestoburpees.com/blog home
  • Result: https://slurpeestoburpees.com/blog-home

##urlencode — Replaces special characters, such as spaces or punctuation marks, with a percent symbol and a series of numbers and letters. Check out this W3Schools URL encoding reference to learn more.

This is useful when your webhook destination URLs contain merge fields. If the value of your merge field contains a space or punctuation marks, you need to encode it for your destination URL to work.

  • For: All fields
  • Example: %5BPage%2F%2FCountry%20%23%23urlencode%5D
  • Example field value: [Page//United States]
  • Example webhook destination URL: https://webhookdestination.com?country=%5BPage%2F%2FCountry%20%23%23urlencode%5D
  • Result: https://webhookdestination.com?country=[Page//United%20States]

Encrypt merged data

Back to top

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.

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

  • The hash value will look like this:

  • Use the ##H:MD5 modifiers to produce a hash value in the MD5 format.

  • The hash value will look like this:

Related university lessons
Page personalization
Include a contact’s name on the page, or adapt your whole page to each visitor – page personalization in Ontraport makes that possible. Learn the basics here.
Personalizing with merge fields
Using merge fields, you can easily include a contact’s name (or more!) on the page for a personalized experience. Learn how to do it here.
Personalizing with conditional display blocks
You can show or hide blocks on a page based on what you know about your site visitors. Learn how to personalize a page using conditional display blocks.
arrow_drop_down_circle
Divider Text
Related support articles
arrow_forward
The Ontraport mobile app
arrow_forward
Sequences and rules

Turn your business on with Ontraport.

arrow_drop_down_circle
Divider Text
This website was designed and built with Ontraport.
About Ontraport
Partners & Integrations
Resources
Getting Started
[bot_catcher]