Capture URL Query Strings in Classic Forms

  • Updated

Query string parameters are variable sets within a URL that can pass data to a Form field when a visitor clicks on the URL. 

With URL query strings, you can:

  • Pass an email address via the confirmation email link for Double Opt-In Forms
  • Capture referral information to pinpoint where a Form visitor came from

You can modify Classic Forms embedded in an Act-On Landing Page or in an inline frame (iFrame) to collect this data using query string parameters. To do this, you'll create a Hidden Field in your Classic Form's Layout and add a snippet of JavaScript in Settings.

Disclaimer: This article relates to Classic Forms, a legacy feature unavailable for new accounts. If you need information on using Act-On Forms, see Forms Composer User Guide.


Add a Hidden Field to Your Classic Form

  1. Go to Content > Forms and create or open an existing Classic Form
  2. In the Classic Forms Composer, hover over an existing field and click New
  3. Select Hidden Field to add a Hidden Field to your Form and click OK
    • You'll need a unique hidden field for each query string parameter. If a parameter does not have a matching hidden form field, the script will skip it and related data will not be saved.
  4. In the Hidden Input Field pop-up, enter a Data Field Name
    • Your Form's Data Field Name needs to match the field name of the query string you'd like to capture.
      • Example: If new visitors enter your Classic Form with the query string [URL]?referrer=Google and you'd like to gather information from the referrer parameter, you should use "referrer" as your Data Field Name.
  5. Leave Data Field Value blank and click Submit

Learn more about using Hidden Fields in Act-On.

Add JavaScript in Your Classic Form's Settings

Forms Embedded in an Act-On Landing Page

  1. Once all Hidden Fields are created, go to Settings
  2. Copy the following JavaScript snippet into the External Web Analytics text area:
var urlParams;
var query = (window.location != window.parent.location) ? document.referrer.split('?')[1] || '' :'?')[1]|| '';
(window.onpopstate = function () {
var match, search = /([^&=]+)=?([^&]*)/g;
urlParams = {};
while (match = search.exec(query))
urlParams[encodeURIComponent(match[1])] = match[2];
for (i in urlParams) {
var urlParamsArray = urlParams[i];
try {
catch(err) {

This code will read the query string from the URL for your Act-On Form if appended to your Form's Public URL.

Learn more about using JavaScript in Act-On.

Forms Embedded in an Inline Frame (iFrame)

Follow steps 1–2 above (under Forms Embedded in a Landing Page) to copy the JavaScript snippet into External Web Analytics.

The above JavaScript snippet will read the query string from the parent page's URL where your inline frame (iFrame) is located. If you'd like to capture a parameter from the framed form's URL instead of the parent page:

  1. Remove the following line from the above JavaScript snippet:

    var query = (window.location != window.parent.location) ? document.referrer.split('?')[1] || '' :'?')[1]|| '';
  2. Replace the removed code with this line:

    var query ='?')[1]|| '';

Create Query Strings in Your URL

To create query strings that will send data to your Classic Form, follow these steps:

  1. Start with your URL
  2. Add a question mark to the end:
  3. Enter the first parameter name after the question mark, followed by an equal sign:
  4. Enter the parameter value after the equal sign.

    • If using a static value (e.g., lead source), enter the value as it should enter the Form (no spaces are allowed here):
    • If using a dynamic value (e.g., an Act-On contact's email address), enter the personalization variable with curly brackets:{{Email Address}}
      • Dynamic variable insertions work with URLs sent within an Act-On email. They are otherwise not recommended.
      • Spaces are allowed when using a personalization variable.
  5. If entering additional parameters, type an ampersand (&) and enter the next parameter and value:{{Email Address}}&FirstName={{First Name}}
    • You may use any combination of parameters. However, an excessively long URL may cause issues loading the page, so proceed with caution.

  6. Once you have all UTM parameters defined, test the URL you’ve created:

    • If the URL has only static values:
      1. Access the URL from your web browser
      2. Make a test Form submission
      3. Review Form submission data in your Act-On Form Submission List
    • If the URL contains any dynamic values, such as personalization, and will be sent via email:
      1. Send a test email with your test URL in the message
      2. Click through the URL when opening your test email
      3. Submit the Form and then review the Form submission data in Act-On

Was this article helpful?

Have more questions? Submit a request