Skip to main content

Pass data into a form with query strings and hidden values

Use query strings and Hidden value blocks to pass data into a form and store it without showing it to respondents.

Written by Gareth Burroughes

Add a query string to your survey or form's link to pass in details such as a campaign name or staff member, and capture them in a Hidden value block that respondents never see.

For example, if each staff member on your website has a Contact me button, you can link every button to the same form and add the staff member's name to each link. The name is stored with each response, so you know who should pick up the enquiry.


Before you start

  • Learn how to build and style in EasyEditor in Design a survey, page, or form with EasyEditor.

  • Hidden value blocks only work when respondents open your survey or form at its direct URL. They don't work in embedded or popup forms.

  • Rules in section logic can't check Hidden value answers.


Add a Hidden value block

  1. In EasyEditor, expand Form blocks.

  2. Drag Hidden value onto the canvas. Respondents don't see it, so place it wherever suits you, such as at the end of the form.

  3. Select the block. Its settings open in the Settings tab.

  4. Enter a Query string key, such as campaign_name. This is the name you'll use in the link.

  5. To save the value to the respondent's contact record, choose a field in Assign to a data field, or select Create new data field. Learn more in Assign form answers to contact data fields.

  6. Save and publish your survey or form.

saf_set_query_string_key.png
hidden_values.png

Add a query string to your link

A query string is the part of a URL after the question mark (?). It holds one or more key-value pairs, separated by an ampersand (&). Each key must match the Query string key of a Hidden value block in your survey or form.

  1. Copy the direct URL of your published survey or form.

  2. Add a question mark (?) to the end, followed by your key, an equals sign (=), and the value.

  3. To pass more than one value, separate each pair with an ampersand (&).

  4. Open the link to check the Hidden value blocks fill in correctly.

For example, this link passes a campaign name and a staff member's name:

https://example.com/form?campaign_name=SeptemberLaunch&staff_member=Alex_Smith

Don't use spaces in keys or values. Use underscores (_) instead, or %20.


Use a query string in an email campaign

To record which campaign a respondent came from, add your link with its query string to the email:

  1. In the email editor, select the text or button you want to link, then select Link on the toolbar.

  2. In the Add a link window, select Hyperlink.

  3. In Link (URL), paste your survey or form link with its query string.

  4. Select Insert.

Don't use Link to a page or Link to a survey.


View hidden values in reports

  1. Go to Analytics > Reports.

  2. Expand More reports and select Surveys, pages, and forms.

  3. Find your survey or form and select the number in the Form responses column.

Each response shows the hidden value it captured. Hidden values also appear in printed reports and exports.


Troubleshoot query strings and hidden values

Problem

What to check

The link breaks or the value is cut short

Remove any spaces from keys and values. Use underscores (_) or %20 instead.

The hidden value is empty in responses

Check the key in the link matches the block's Query string key exactly, and that respondents opened the direct URL, not an embedded or popup form.

The form doesn't work on your custom domain

Try the link on your default Dotdigital Marketing domain. If it works there, the problem is with your domain delegation.

To keep a value you already hold for a contact off the form while still collecting it, use Hide this question instead. Learn more in Assign form answers to contact data fields.

Did this answer your question?