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

The Hidden value element allows you to include a value from the query string as part of your survey or form response.

It won't display as part of the survey to your respondent, but once your survey has at least one response, you'll then be able to view the hidden value in reporting.

saf_hidden_value.png

Why it's useful

Let's assume you have a list of staff on your website, and next to each one you have a 'contact me' button. The button links to a form that collects a visitor's contact details - but how do you know which 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 element. 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 the left-hand side panel (under 'Query string key'). 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?

  • Avatar

    is it possible to append the query to the embed script?

  • Avatar

    Hi Amir and Kellie. Thank you for your questions, which I wanted to address.

    Amir - it is possible to pass a timestamp value in a hidden field. Depending on the format of your timestamp value, you might even be able to assign it to a date/time contact data field in dotmailer. However, this should be tested effectively to make sure it works before relying upon it. And just to be clear, so there's no misunderstanding, you'd need to be generating the timestamp value from your side. Our surveys and forms tool can't automatically generate a timestamp value for you. It can, however, pass one.

    Kellie - you're not able to append the query string to the survey embed script. It has to be added to the webpage that the survey is embedded in, i.e. the URL seen in the browser address bar. Depending on how you're looking to use the hidden field value, there are other options you might be able to use. For instance, if you're looking to use it to show which webpage a survey was filled in on, you could duplicate the survey for each page and then merge the responses from reporting.

    Hope that helps.

  • Avatar

    This appears to do what it says on the tin, I can see the response from the query string within my results. However, while all other values synchronise back to our Microsoft Dynamics instance the (critical) hidden value is not.

  • Avatar

    Hi Tom. Thanks for raising this. As it stands, hidden field responses in a survey aren't synced to the Dynamics connector. We plan to make this available soon though, so look out for that!

    In the meantime, you could assign the hidden field value to a contact data field in dotmailer, and then map the contact data field to a field in Dynamics. This way it would sync for a respondent who's a contact.

  • Avatar

    Great thanks Neal! I know dates are hard to pin down but as a rough idea of when this will be available would "this year" be reasonable?

    Unfortunately pinning the result to a contact data field isn't suitable in our current scenario as each contact can respond more than once and the hidden value will change each time and so the data field will also update each time and I will lose the previous response.

  • Avatar

    Whilst I can't make any promises, availability before the end of the year is likely, yes. Keep a look out in our fortnightly release notes posted here - https://support.dotmailer.com/hc/en-gb/sections/202602098-Feature-releases.

  • Avatar

    Great thanks, will keep an eye out!

  • Avatar

    Hey Neal - related to this, is it possible to pass field responses out of the survey and into the redirect querystring on completion, e.g. redirect to:

    www.blah.com?email=myemailfromsurvey@gmail.com