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
Find free content on the latest marketing strategies, using Ontraport in your business, and finding the right software.
Visit the blog
University Pricing Chat
Pass URL variables to pages
Last updated on: February 28, 2023

Ad hoc merge fields give you extra flexibility when personalizing pages. That’s because they allow you to insert dynamic content on the fly. Regular merge fields pull data from your records, and ad hoc merge fields use the URL to insert content into your page. These fields make it easy to customize your pages without creating custom fields or masking the field name you want to prefill.

How do ad hoc merge fields work?

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

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 [Page//int] with the value “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.


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:
  2. Add your ad hoc field names:
    • 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:

Using your custom links

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

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.

Related university lessons
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.
Form settings and advanced features
Learn all the form settings and advanced features in Ontraport Forms, from opt-in settings to notifications and more.
Multi-step forms
Get more form fill-outs by breaking them into bite-sized chunks. With multi-step forms, create several linked pages.
Divider Text
Related support articles
Create and use PURLs
Display your Ontraport Page on your Wordpress site
Page elements
 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 [Page//ad hoc] to your page, your visitors will see "[Page//ad hoc]" unless you pass a value for it with a custom link.
Live events
© Ontraport 2024
PCI DSS, Level 1
Privacy Shield Certified