Auto-Fill a Form Using the Form URL

Sometimes, it can be useful to provide a link to your web form that automatically inserts some data into the form. An example of this would be to automatically insert a referral number into a common contact form so you can use one contact form across multiple websites. That is the example we’ll show how to set up today.

 Let’s say you have three different websites that all need contact forms. Instead of creating a separate contact form for each website, you can use the same contact form for all three. The secret is using auto-population to pre-fill a read-only field on your form that provides a reference number that tells you where the contact form came from.

 First, add a short answer field to the top of your Contact Form.

Screen_Shot_2019-06-18_at_10.11.28_AM.png 

This field will be the one you'll pre-populate with your referral number so you will know which site the customer came from. Make the field hidden so it is only visible in your submission data and not on the form.

Screen_Shot_2019-06-18_at_10.12.34_AM.png

You'll need your form's URL for this next part. You can find it by clicking on the "Publish" tab. This particular form's URL is:

https://formstackhq.formstack.com/forms/autofill

Next, add something called a query string to your published form's URL. This will allow you to specify a field name and the number you want to automatically show up inside that field.

To add a query string to your form's URL start with a question mark, then add the field name in all lower case letters. If the field name is two words connect them with an underscore. Finally add an equal sign and the value you'd like to populate the field with. Let’s say your first website's referral number is 123456. Tell the form (via the URL) that anyone that clicks on this link came from that website. So, the query string for this example would be:

?referral_number=123456

Our completed URL is now:

https://formstackhq.formstack.com/forms/autofill?referral_number=123456

Click on the above link to see it in action (The referral number field at the top of the form has been unhidden so you can see the number appear.

Now, just change the number "123456" in your link to the referral number of your other two websites (or any number of websites) and you can reuse this contact form for any website you have. All your submissions will include the referral number of the site, so you will know where your visitor came from.

Was this article helpful?
10 out of 17 found this helpful

Comments

0 comments

Please sign in to leave a comment.