30% Off WS Form. Limited Time Only. Unlock Deal

How to Set Fields Based on the Referring PagePRO

Ever wanted your forms to feel a little smarter? For example, imagine linking to the same form from your Pricing page, your Features page, and your Contact page and having the form automatically adjust its default values depending on where the visitor came from. With WS Form, you can do exactly that.

In this tutorial, we’ll walk through two simple methods to make it happen: using the Referring URL and using a Query String Parameter.

Demo

By Referring URL

A referrer is the URL of the webpage that a visitor came from before arriving at the current page.

You can populate a field with the referrer (e.g. a Hidden field) and then use conditional logic to check what the referrer contains.

1. Enable Referrer Tracking

  1. Click on the Form Settings icon.
  2. Click on the Tracking tab.
  3. Check Tracking > Referrer.
  4. Click Save & Close.

The variable #tracking_referrer can now be used in your form.

2. Add a Hidden Field

The referrer variable #tracking_referrer can now be used in your form. Let’s add that to a hidden field.

  1. Add a Hidden field to your form.
  2. Edit the Hidden field.
    1. In the Label setting, enter: Referrer
    2. In the Default Value setting, enter: #tracking_referrer
  3. Click Save & Close.

3. Add Conditional Logic

You can now use conditional logic to check the referrer, for example if the user came from the page:

https://mysite.com/pricing/

You could preselect the “I need an estimate” option in a Select field:

IF [Referrer] [Contains] "pricing"
THEN [Interested In] [Select Row] [I need an estimate]

By Query String Parameter

A query string parameter is extra information in a page URL after a ? (and separated by & if there are multiple). You can use these parameters to pass context between pages.

1. Add a Query String to Your Link

For example, when linking from your pricing page to the inquiry form:

https://mysite.com/inquiry/?r=pricing

Then you could extract the value of the “r” query string parameter using:

#query_var("r")

2. Add a Hidden Field

  1. Add a Hidden field to your form.
  2. Edit the Hidden field.
    1. In the Label setting, enter: Query String Parameter Value
    2. In the Default Value setting, enter: #query_var("r")
  3. Click Save & Close.

3. Add Conditional Logic

Just like with the referrer method, you can use conditional logic. For example:

IF [Query String Parameter Value] [Contains] "pricing"
THEN [Interested In] [Select Row] [I need an estimate]