Using hidden fields to include values from the query string

Contents

Why it's useful
What is a query string?
Setting it up
Viewing the hidden value

Summary

You can include a value from the query string as part of your survey or form by using the Hidden value field.

The Hidden value element allows you to include a value from the query string as part of your survey or form response. It will not display as part of the survey to your respondent, but once your survey has at least one response, you can view the hidden value in reporting.

Survey hidden form interface

Why it's useful

Let's assume you have a list of staff on your website, and next to each you have a 'contact me' button. The button links to a form that collects a visitor's contact details - but how do you know what staff member they wish to contact? You could create a form for each staff member, but that sounds like a lot of work. Instead, you can include a hidden value on the contact form that pulls in the staff member from the query string. Each contact button can then include the member's name in the link, and you only need one version of your form.

diagram-hidden-value-600.png

What is a query string?

The query string forms part of a URL - it's the bit that starts after the question mark. For example, in the link:

https://www.google.co.uk/?q=survey

The query string is 'q=survey'. Query strings let you pass keys and values as part of a URL. In this example, 'q' is the key and 'survey' is the value. You can have multiple keys and values.

Setting it up

The Hidden value block

  1. Using the scenario above, let's assume your links from the contact buttons look something like http://[surveylink]?staffmember=joe
  2. In the survey editor, drag in the Hidden value field. Although the field won't show to your respondents, it will show to you in reporting - so locate it somewhere that makes sense (often putting it as the last field in a survey is a good option).
  3. Make sure the field is selected, and enter the key of the value you want to pull in. In our example, the key would be 'staffmember'.
  4. Optional: You can also assign this value to a contact data field (see our guide on this for more details).
  5. Save the survey as usual.

Now, when you link to the survey with a URL that includes the 'staffmember' key on the query string, the value will get included in the survey's response.

Viewing the hidden value

Once your survey has at least one response, you can view the hidden value in reporting.

  1. Go to the reporting of your survey
  2. Click on the Responses tab, and open up a response. The Hidden value field will be shown, along with the value supplied.

The values are also included on reports and exports.

Have more questions? Submit a request

Comments

  • Avatar

    This article says you can have multiple keys and values... Please can you tell me how to write that in your query string to pick up individual values which need to be assigned to separate contact data fields?

  • Avatar

    Hi Tanya. Yes, multiple keys and values are separated by an ampersand in a query string. For instance, if you have 'field1', 'field2' and 'field3' then your query string would look like this:

    field1=value1&field2=value2&field3=value3

    Hope that helps.

  • Avatar

    Are you able to pass a time stamp in a hidden field?

Powered by Zendesk