How to use the hidden field block
Hidden fields are like hidden gems. Use them to make your forms and surveys more personal. Or keep track of your respondents or other information you pass to the form.
When to use
The idea of a hidden field block is you're able to gather information from outside the form into your form's dataset. That information is then saved with the rest of the form data when the form is submitted. Some examples:
- Get the name of a respondent from a query string parameter and show it in your form;
- Save the URL of the page that your form is embedded into;
- Make a logic branch in your form based on the device size of the respondent.
WordPress only: WordPress variables
In your WordPress plugin the hidden field block offers an extended list of WordPress variables that you can use to instantly collect WordPress specific data, for example:
- User information of the logged in WordPress user, like the name and email address;
- Website data, like the URL and language;
- Visitor data, like the IP address and the referrer URL;
- Server data, like the WordPress version and PHP version.
Please have a look at this article about how to use WordPress variables in your form.
How to use
The hidden field block is available as a question type. Add a new block to your form and then select the question type
Hidden field. You can add it in any given position and in an unlimited amount inside your forms.
You can now change the features of the block to get the desired behavior:
The name of the field in your form (not visible for respondents).
Type of field
This determines the type of information you want to get. Examples of field types are a query string, a cookie, a page URL, a timestamp and browser information (like the user language).
In the WordPress plugin you can also instantly use WordPress variables.
Depending on the selected type of field, additional features and settings can become activated to help you get the right value in your hidden field. These features will popup on the left side of the pane. You can enable and configure these to your own needs.
After you retrieved a hidden field in your form, you can instantly use that value to execute logic based on the value of the hidden field.
You can show the value of the hidden field to your respondents, by using our piping logic. This works the same way as you can use 'normal' question blocks as piping values, like you can see in this article about piping logic.
You can also use the value of the hidden field as branch conditions, so the form can take decisions based on the hidden field. This works the same way as you can add logic based on 'normal' question blocks, like you can see in this article about branch logic.
Due to the flexibility of the hidden field block, the value that it generates can contain several types. It depends on the type of value that is saved inside the hidden field, which branch conditions you can create with it.
Please see the following articles for the possible branch conditions:
- Branch conditions for textual values;
- Branch conditions for numeric values;
- Branch conditions for date (and time) values.
You can use the calculator block to perform calculations with hidden fields. Due to the flexibility of the hidden field block, the value of it can contain several types. It depends on the type of value that is saved inside the hidden field, which calculation operations are available in the calculator block.
Let us show you some examples of how to use the hidden field.
Get page URL
Let's say you have embedded a Tripetto form into various pages inside your website and you want to know from which page someone has submitted a form. The hidden field can simply gather the page URL of the page that the form is embedded into and save that data to the entry data.
Get value from query string
The URL of a form/page can also contain certain values. Those are often stored in the query string of the URL (what's a query string?). The query string is at the end of the URL and can contain fully flexible name-value pairs.
About query strings
A query string is a somewhat technical tool to send data in a URL. Some background information on how to supply a query string:
- You can add multiple parameters to a query string;
- Each parameter consists of a name and a value, separated by a
=sign, for example
- The first parameter is preceded by a
- Any following parameters are preceded by a
A full example could be something like this:
Let's say we have a form that we share via different channels, for example a mailing and Twitter. And you want to know how someone entered the form, so you can analyse which channel worked best. By adding a query string named
referral to your URL's, you can add various values for that query string parameter that can be saved in a hidden field in the form.
So in the URL you share via a mailing the query string in the URL is something like
?referral=mailing. And for the URL you share on Twitter something like
?referral=twitter. Notice that all parameter names and values we use are just examples; those are totally flexible for your own needs.
Now, by adding a hidden field that reads the query string parameter
referral, you can save where someone came from. Each entry will now contain where someone came from: the mailing, or Twitter.
Also read our blog
We also wrote a blog post with some more background information, use cases and working examples of hidden fields.