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
Pass URL variables to pages
Last updated on: October 30, 2024

Personalized pages and forms create the ideal customer experience. One way to provide this is by passing contact information through the page URL using a custom link that you create. For example, if you pass a lead’s vertical through the URL, you can personalize your demo page before the lead ever opts in.

In most cases, you can add merge fields to your pages, and Ontraport will use visitor cookies to fill them in with contact data.

You can also create custom links to pages that allow you to pass information to pages through the URL and populate merge fields on the page. This is helpful if you don’t have a contact record to pull from or want to avoid relying on cookie data to personalize pages.

You can pass two types of merge fields through URLs:

  1. Ad hoc merge fields — These merge fields allow you to insert dynamic content on the fly. They use the URL to insert content into your page and make it easy to customize your pages without creating custom fields or masking the field name you want to prefill. 
  2. Standard merge fields — These are the normal merge fields you’d add to pages and emails, but with a little bit of formatting you can use them to pass information through the URL.

Learn more about personalizing your pages in this video.

Table of contents

How do ad hoc merge fields work?
Create custom links with ad hoc merge fields
Using your custom links
Use ad hoc merge fields to show/hide content
Create custom links with standard merge fields

How do ad hoc merge fields work?

Back to top

When you use ad hoc merge fields, you need to add the name of your merge field and its value in your URL. If the ad hoc merge field on your page matches the merge field in your URL, your page will automatically fill it in with the value from your URL.

The example below shows ad hoc merge fields on a page. However, you can also use them to prefill visible and hidden fields on forms.

This process can help collect information about new leads before they opt in. For example, say your homepage includes links to different topics. You can use ad hoc merge fields to save new leads’ interests based on what they clicked before opting in. 

And the ad hoc merge fields allow you to mask the field you’re populating with a simpler term. For example, if you want to prefill a “Lead interest” field, you could replace the label with something simple like “int” for a cleaner-looking URL.

Create custom links with ad hoc merge fields

Back to top

Pass the information you want to send by attaching a few parameters to the end of your custom link. Before you begin this process, be sure that the page you are creating a link for is already published.

Here’s an example of a link to a cardio fitness page that populated the ad hoc merge field [int] with the value “cardio”:

https://slurpeestoburpees.com/cardio?int=cardio

Creating these links is more manageable than it might seem. You will need your URL, an ad hoc field name and a value first.

URL: https://slurpeestoburpees.com/cardio

Ad hoc field names: Any text you want

  • The only stipulations are that the merge field in your URL must be URL encoded — spaces need to be replaced with “+” or “%20” — and it must match the merge field you add to your page.

Value: The value you’d like to use to replace your ad hoc merge field

All that’s left is putting them together. There are a few characters you need to add to your link to string your parameters together:

? – This will go at the end of your URL. It should go directly after your top level domain — don’t add a “/” at the end.

+ – This will replace the spaces of your field names. 

= – This matches your field name to your merge field. 

& – This can be used to add multiple fields in your URL.

Follow these instructions to put it all together:

  1. Start with your URL, and add “?” at the end of it: https://slurpeestoburpees.com/cardio?
  2. Add your ad hoc field names: https://mysalespage.org?int
    • If your ad hoc field name includes spaces, replace them with “+.”
  3. Add “=” and the value you want to replace your merge field with.
    • If your value includes spaces, replace them with “+.”
  4. Add “&” and start again at step 2 if you have another field you would like to pass:  https://mysalespage.org?int=cardio&goal=heart+health

Using your custom links

Back to top

Once you’ve created your links containing ad hoc merge fields, you’re ready to implement them. 

If you want to use your links in an email, you need to hyperlink them in your message. 

If you’re going to prefill form fields or hidden form fields with your ad hoc values, follow the steps in this article.

  • Always use the “set manually” option with ad hoc merge fields.

Use ad hoc merge fields to show/hide content

Back to top

Another helpful way to use ad hoc merge fields is to show/hide content. To do this, you’ll use the “Only show this block if the page URL contains specific text” display option on your block display settings.

This is a helpful way to customize your visitors’ experiences based on their activity on your site, even if they haven’t opted in.

For example, imagine you have a page with links to all the states where you’re running events. When a visitor clicks on your “Washington” link, it adds an ad hoc merge field in your URL. If that URL sends visitors to your “Events” page, your page will display only the Washington events.

Create custom links with standard merge fields

Back to top

Before you begin this process, be sure that the page you are creating a link for is already published. When you create your custom link, you can add the information you want to send by attaching a few parameters to the end of your URL.

Here’s an example of a link to a sales page that sends a contact’s first and last name to the page:

https://mysalespage.org?First+Name=[First Name]&Last+Name=[Last Name]

Creating these links is less daunting than it might seem. What you’ll need is your URL, the names of the default fields you want to pass, and the merge fields for those fields.

URL: https://mysalespage.org
Field Names: “First Name” and “Last Name”
Merge Fields: “[First Name]” and “[Last Name]”

All that’s left is putting them together. There are a few characters that need to be added to your link to string your parameters together:

? - This will go at the end of your URL. It should go directly after your top level domain — don’t add a “/” at the end.
+ - This will replace the spaces of your field names.
= - This matches your field name to your merge field.
& - This can be used to add multiple fields in your URL.

Follow these instructions to put it all together:

  1. Start with your URL, and add “?” at the end of your URL: https://mysalespage.org?

  2. Add your field names formatted with “+” replacing spaces: https://mysalespage.org?First+Name

  3. Add “=” and the matching merge field; you can leave spaces in this one: https://mysalespage.org?First+Name=[First Name] 

  4. Add “&” and start again at step 2 if you have another field you would like to pass:  https://mysalespage.org?First+Name=[First Name]&Last+Name=[Last Name] 

Related university lessons
Form settings and advanced features
Learn all the form settings and advanced features in Ontraport forms, from opt-in settings to notifications and more.
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.
Multi-step forms
Get more form fill-outs by breaking them into bite-sized chunks. With multi-step forms, create several linked pages.
arrow_drop_down_circle
Divider Text
Related support articles
arrow_forward
Designing for mobile devices
arrow_forward
Display your Ontraport Page on your Wordpress site
arrow_forward
Use global blocks on pages
 Pro tips
Tip #1: If you type in an ad hoc merge field to your page and the URL doesn’t pass that variable, your merge field will be visible on your page.
This behavior is one of the significant differences between adding ad hoc merge fields to your page and regular merge fields. For example, if you add [ad hoc] to your page, your visitors will see "[ad hoc]" unless you pass a value for it with a custom link.
Features
Company
Resources
Live events
Access
© Ontraport 2024
playlist_add_check
PCI DSS, Level 1
security
Privacy Shield Certified
[bot_catcher]