Site icon JD Bots

How to Pre-fill an n8n Form with Query Parameters

Card titled Pre-fill an n8n Form with Query Parameters, labelled n8n how-to, forms, with a form icon and three query parameters: an encoded email address for Email, Topic set to Events, and source set to instagram for a hidden field.

An n8n form can open with some answers already filled in. You add them to the form’s link as query parameters: values written after a ?, such as ?Email=jo%40example.com. A link in a newsletter can then fill in each reader’s email address, and a hidden field can record where the visitor came from.

In this guide you build a small newsletter sign-up form, open it from a link that fills in two fields and a hidden field, and see what n8n receives.

Syntax

A pre-filled form link is the form’s address followed by the fields to fill in:

Syntax

<form URL>?<field>=<value>&<field>=<value>

n8n’s Form Trigger docs describe query parameters and percent-encoding.

Step 1: Build a Small Form

Create a new workflow named Newsletter sign-up and choose On form submission as its first step. Type a Form Title and a Form Description, then add a form element Email of type Email, with Required Field turned on:

The form’s title, description and Email field.

Add a second element, Topic, of type Dropdown, with the options New books and Events.

Step 2: Add a Hidden Field

A hidden field isn’t shown on the form, but its value is sent with the answers, so it can record where a visitor came from. Add a third element and set Element Type to Hidden Field. Click Add Attributes and add Custom Field Name, then Field Value:

A Topic dropdown, then a hidden field and its attributes.

Set Custom Field Name to source and Field Value to website, the value it keeps when a link doesn’t set it. Under Options, add Form Path and type newsletter, so the form’s address ends in /form/newsletter:

The hidden field source, with website as its default.

Step 3: Publish the Workflow

Close the node and publish the workflow. n8n’s docs say query parameters fill in fields only on the published form, at its Production URL. In On form submission, open Form URLs › Production URL to see it. On this n8n, it’s:

Production URL

http://localhost:5678/form/newsletter

Step 4: Add the Values to the Link

Add ? to the address, then each field and its value, with & between them:

Form link

http://localhost:5678/form/newsletter?Email=jo%40example.com&Topic=Events&source=instagram

%40 is the @ of the email address. Open the link in your browser. Email and Topic are already filled in:

Email and Topic come from the link.

The hidden source isn’t on the page, but its value goes with the answers.

Step 5: Submit and Check What n8n Received

Click Submit, and n8n shows its Form Submitted page. Back in n8n, open the workflow’s Executions tab, click the newest run and open On form submission:

source is instagram, taken from the link.

source is instagram, from the link, instead of the default website. n8n also lists every value that came in the link under formQueryParameters.

Clean Up

Unpublish the workflow so the form stops taking sign-ups, then archive and delete it from its ⋯ menu.

Common Mistakes

MistakeWhat happensDo this instead
A field name in lower case, such as email=The field stays emptyWrite the label exactly as on the form: Email=
A dropdown value that isn’t one of its options, such as Topic=PoetryThe dropdown shows its first option, New booksUse one of the options, written exactly

FAQ

Does the test URL fill in the fields too?

n8n’s docs say no: query parameters work only on the production URL. In n8n 2.49.5 the test URL filled them in as well, but use the production URL for links you share.

Can visitors see or change a hidden field?

They don’t see it on the form, but its value is in the link, where anyone can change it. Use it for things like where a visitor came from, never for anything that must be trusted.

Does every page of a multi-page form get the values?

Yes. n8n’s docs say every page of the form receives the same query parameters, so a field on a later page can be filled in from the same link.

Conclusion

Add ? and field=value pairs, joined with &, to an n8n form’s production URL to open it with answers filled in. Write each field’s label exactly, percent-encode special characters, and add a hidden field to record where visitors come from.

Additional Resources

Related

n8n and other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by n8n GmbH.

Exit mobile version