Within Campaignion it is possible to set up conditional form fields. This piece of functionality is really new, so it's not yet in the main interface. We will be adding this to the interface in the future, but for now, here's how you can use this feature.
What are conditional fields and why would I use them?
There are loads of things you can use conditional fields for. Here are a few ideas:
- Using the same form for single and regular donations, hiding and revealing fields depending on whether the user chooses to give a one-off or regular gift.
- Hiding or changing opt in boxes for people already on your list.
- Running surveys or other flexible forms where answers to some questions determine which other questions you ask, and how.
How to use them
First, set up your form and include all fields that you might need. Once all of these fields are available, add "/webform/conditionals" to the end of your form URL. If you can't access this page you may not have been granted permission to do so. You can read more about permissions here.
yourCampaignionURL.org/node/11/webform/conditionals (You need to change the purple bits)
On this page click 'Add new condition' and use the plus buttons and drop down options to set how you'd like your form to behave. Here's an example of what this looks like where elements are hidden depending on whether the user chooses a single or regular donation interval at the first form step.
Here's the list of conditions available:
Submitting values in the URL string
In addition to using values submitted by the user in the form, you can also make form fields conditional on values submitted in the supporter's URL. This can be used for changing the opt in language or content for people already on your list.
To submit a value in the URL string, you need to use this format:
You find the form field key on the form page of the action builder, and the value can be whatever you like. If you want to use more than one parameter, you can separate these with an &. For example:
(you only need the # once).
URL string pre-population can be used really well with hidden fields to make changes without the user being able to see it happening.
Using hidden or private fields
You can use as many private or hidden fields as you need. Hidden and private fields allow you to control what values are on the form without needing to have a visible field with a certain value. This allows you to adapt the forms to the user without them knowing you're doing so. It's entirely up to you whether you use private or hidden fields.
Private fields are fields that are only visible to logged in users, i.e. staff. Most fields can be turned into private fields simply by toggling 'private' to on in the form editor.
You can see them in the form fields palette on the right hand side in the form builder:
Each hidden field will need a unique key. Try to label these clearly so you can tell what they do just by reading the name.
The hidden fields should be added to your first form step.
If your hidden form field was added to your page before 21st February 2018 it may not work like this by default. Click here to see how to make it editable through the URL parameters.
A common usage for hidden or private fields is to indicate whether the user is already on your list and then to change or hide the opt in and data protection statements shown. Here's how you could achieve this using a hidden field:
- Make sure all possible variations of the statement/optin boxes are on your form
- Add a hidden field to the first step of your form and call it 'onlist' (you can use whatever value you like)
yourCampaignionURL.org/node/99/webform/conditionalsand set it so that the contents of the onlist field will determine which form fields are hidden.
- When sending out emails add the parameter onlist=yes to their URL to make sure that the correct fields are hidden for people already on your list. e.g.
If you're using tracking parameters in the URL they go before the #
When using hidden fields remember to think through every scenario. For example a supporter could forward their email to a friend, complete with the parameters you've personalised for the person on your list. Therefore make sure you don't use the parameters to check an opt in and then hide it as then you could accidentally opt in the friends without their consent.
On the 21st February we rolled out an update making all new hidden fields editable through a URL parameter by default. But if you added your hidden field to the page before this date, you will need to follow these steps to make it work as described above.
Once the fields are on the form, save the form and visit:
yourCampaignionURL.org/node/11/webform/components (again, the purple bits need changing to match the form in question).
The content, or lack thereof, of these fields can be used as a condition.