Company Blog Support
Frank Hagan


    Back to Top

    Passing URL Variables to Pages

    About Passing URL Variables

    ONTRAPORT Pages v3 ("Pages") can parse variables added to the URL. These variables can be used to populate merge fields on the page or fill in Pages native forms. The variables work on SSL Pages as well as non-SSL Pages.

    URL variables are also called "URL query strings" or "URL parameters". Here's an example using the first name and last name "Jack Spratt":

    The standard format is to have a question mark at the very beginning of the variables as shown above. Then, each variable has a label or identifier, an equals sign and the value for the variable. Multiple variables can be added by separating them with an ampersand, as shown above.

    Note: This feature does not populate fields in an ONTRAform used on the Page. Only native Pages forms, created in the Pages editor, can receive the values. 

    Why Use URL Variables

    1. It's the only way to merge data from the contact record onto secure pages. So, if you want to send someone to an order form and put their name (or whatever) on the page to personalize it, then you'll use this feature.
    2. You can pre-fill form values, to make it easier for your people to submit forms and order forms. Again, for secure pages, this is the only way to do this.
    3. Coming soon: Internal referral tracking! Say you want to track which of your sales reps drove an online sale. You may not want to put them in your affiliate/partner program because that would mess up referral tracking. So, you need a different way to track it. One way would be to have your reps send their prospects links with their id or name in the url: Then, you can use that salesrep variable to prefill a hidden field on your order form. (Note: hidden fields coming to Pages very soon!)

    Passing Variables From ONTRAforms or Legacy Smart Forms

    URL variables cannot populate a legacy Smart Form or ONTRAform, but these forms can send the information they collect to a Page. Set the Page as the "Thank You" page for the form. Then, in the form's settings check the "Pass CGI variables to the Landing / Thank you page".

    The field data collected on the form will be added to the Thank You page's URL. ONTRAPORT formats the URL with the variables as shown below so no additional configuration is needed.

    Passing URL Variables in an Email Link

    You can build the URL variables for links in email and on Pages. Add the URL variables after the base URL in the link editor. The format is an identifier for the field, an equals sign, and the value. The value can be a literal string or a merge field. You can use standard merge fields for the value if sending the email from ONTRAPORT.

    firstname=[First Name]

    Start the variables with a question mark after the base URL and use an ampersand between the variables.  

    ?firstname=[First Name]&lastname=[Last Name]

    Remember that the URL variables are appended to the base URL, as shown here:

    Adding merge fields to pass as variables to the target Page

    If you are sending a literal string with spaces, convert the spaces to either a plus sign or %20 as shown here between "von" and "Mises" in the last name:

    Note: Do not convert the spaces in an ONTRAPORT merge field, as ONTRAPORT will take care of populating the merge field and applying the necessary encoding.

    Prefill Form Fields on Secure Pages (SSL)

    The variables you pass in the URL can prefill the Page's Smart Form and Order Form fields. Use the field name as the identifier in the URL. The field name is "firstname" in this example.

    Then, use the  the same field name in the form field as the Placeholder, with brackets.

    The URL will prefill this First Name field in the order form above with "Jack" because the field name in brackets - [firstname] - matches the identifier in the URL variable. 

    SSL pages cannot use the standard merge codes to prefill form fields.

    Remember, this limitation is only on the secure page's side. If you are sending the link to the secure page using an ONTRAPORT email you can still use the merge field to build the URL variable. It is the identifier that must be the field name alone, without brackets, in the URL. Both of these URLs would prefill the First Name field on our order form:[First Name]


    Here are common field names and the merge fields corresponding to them:

    Field Field Name Merge Field
    First Name firstname [First Name]
    Last Name lastname [Last Name]
    Email email [Email]
    Address address [Address]
    City city [City]
    State state [State]
    Zip Code zipcode [Zip Code]
    Country country [Country]
    Company company [Company]

    To obtain a list of all your account's form fields, including custom fields, use our Live API Doc. Input a valid API Key and APP ID at the top of the page and click the "Try it Out" button in the /Contacts/Get Meta/ section. Custom fields have an alphanumeric name starting with "f" and four digits. The merge field is shown as the "alias":

    Populating Hidden Fields

    Coming soon!

    Populating Merge Fields on the Page

    Standard ONTRAPORT merge fields will populate with the URL variables if the identifier is a field name. Inserting the [First Name] merge field on the Page, then passing a URL variable ?firstname=Jack will have the merge field replaced with "Jack". Standard merge fields "disappear" if not filled.

    Ad Hoc Merge Fields

    You can create your own merge fields that don't require a field in the Contact or custom object record. Specify them in the URL variable and then have the same name in brackets on the Page. "?New+Merge+Field=This+is+new" would populate a merge field [New Merge Field] on the page with "This is new". However, if the variable is not passed by the URL the merge field is displayed in plain text on the page as [New Merge Field]. Ad hoc merge fields do not disappear if not populated like standard merge fields do.


    • URL variables take precedence over PURLs and cookie data. This allows them to be used for secure landing pages. 
      • Caution: Passing a literal "?firstname=Jack" URL variable to Page with a Smart Form to prefill it will, upon submission, change the Contact's first name to "Jack". 
      • Use ONTRAPORT merge fields where possible.
    • Normal ONTRAPORT merge fields will "disappear" if not populated, so "Hi [First Name] -" becomes "Hi -" if no value is passed for the firstname field.
    • Ad hoc merge fields are always displayed. If no value is passed, they will show the original value such as [New Merge Field].


    URL variables are not secure when passed to a non-SSL (HTTP) page. When passed to a page protected by SSL the entire URL is encrypted, but may be stored in plain text form in server logs. We do not recommend sending personal information via URL variables. 

    Articles in this section

    Created - Updated
    Have more questions? Submit a request


    Powered by Zendesk