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
- Click on the Form Settings icon.
- Click on the Tracking tab.
- Check Tracking > Referrer.
- 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.
- Add a Hidden field to your form.
- Edit the Hidden field.
- In the Label setting, enter:
Referrer - In the Default Value setting, enter:
#tracking_referrer
- In the Label setting, enter:
- 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
- Add a Hidden field to your form.
- Edit the Hidden field.
- In the Label setting, enter:
Query String Parameter Value - In the Default Value setting, enter:
#query_var("r")
- In the Label setting, enter:
- 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]