Collect User Surveys with a Drupal Webform
The Drupal webform module makes it easy for you to design and deploy detailed surveys for collecting information from your users. It also facilitates the analysis of the collected data by providing both web-based statistics and point-and-click Excel export capabilities. In this tutorial, we'll scratch the surface of what a Drupal webform can do by designing a simple student information form.
- Webform is completely free software, but it is not installed and enabled by default in the CWS Drupal distribution. If you'd like to use it on your site, just let us know and we'll get it installed as soon as possible.
- In the menu at the top of the screen, choose "Content management > Create content > Webform".
- You can give your new webform a title, description, and place in the menu hierarchy just the same as you would for any other Drupal node (see our Drupal First Steps tutorial for more information).
- You can also provide a "Confirmation message or redirect URL"; if you enter a URL in this field, users who submit your survey will be taken to that URL after they're done. Alternatively, you can enter content directly into this field, which the user will see when he or she has completed the survey.
- In our example, we're only interested in feedback from current UNT students; in our Drupal distribution, UNT students automatically have the role "untst". So, under "Roles that can submit this webform", check the "untst" role and uncheck everything else.
- If you'd like to receive users' form submissions via email, enter your email address in the "E-mail to address" field.
- When you're finished adjusting the basic settings to your liking, click the "Save" button at the bottom of the page.
You should note that, unless you specified otherwise in "Publishing options", your webform node will not yet be publicly accessible. This is a good thing, as it gives you some time to set up the data fields you'll be collecting.
Creating Form Fields
Now that your webform node is set up, it's time to add some fields. For this sample form, we've decided to collect the student's email address, birthdate, favorite professors, and brief biography.
The Email Address Field
- In the "New component name" text field, enter "Email Address".
- In the "Type" column next to it, choose "email". This will help Drupal validate users' form submissions (for instance, if a user accidentally enters a phone number here, Drupal will remind the user to correct the error before submitting the form).
- If you check the "Value Mandatory" checkbox, users will be required to provide a value for this field before submitting the form.
- If you check the "E-mail" checkbox, the user's entry for this field will be included in the email summary you receive from the system. Since email is so often insecure, it is very important that you do not check this checkbox if you are collecting potentially sensitive information; generally, you should not be collecting such information in the first place, but if you need to, please consult email@example.com to make sure you are in compliance with relevant university policies.
- Click the "Add" button.
- On the next page, you can configure several more settings for the field. Most of these are fine by default, but a few of them are worth considering before you click "Submit". For example...
- If you check "User email as default", Drupal will automatically fill in users' email addresses for them, provided they are logged in.
- The "Description" provided here will be displayed underneath the form field as help text; it allows you to specify in greater detail what this field is for and what kinds of information the user should supply.
- If you check "E-mail a submission copy", Drupal will send the user a copy of their form submission (in addition to sending it to you). This allows your users to have a record of what they've sent you.
The Birthdate Field
The basic process for creating form fields is the same every time; however, there are a couple of differences based on the types of fields you create. For birthdate, we want the user to be able to select a date have it automatically formatted in a certain way for consistency. This is very easy to set up:
- When creating the field, choose "date" as its "Type".
- As appropriate, you can set a valid range of years; for instance, since we're only interested in current students, we can safely set a maximum year of, say, 1994 (anyone born earlier than that probably isn't in college yet, at least not as of this 2009 writing).
The Favorite Professors Field
For the sake of this tutorial, assume that our department has exactly three professors, and we want students to be able to choose which of those professors were their favorites.
- In this case, you'll want to choose "select" as the field type.
- On the following page, enter the names of the professors into the "Options" field; each professor's name should be on its own line.
- We don't want our students to have to choose just one of our professors, so down towards the bottom of the page, check "Multiple". This will allow them to select as many (or as few) as they like.
- In our example we only had three professor options; however, if you've got quite a few more options than that it might be worth checking the "Listbox" option. This will cause Drupal to render the options in a scrolling list box instead of as a set of checkboxes.
The Biography Field
You can also collect lengthier responses from your users by creating "textarea" fields; this is what we'll use for the biography field. The process here is identical to what you see above, so there's no need to repeat the instructions.
When you're finished adding fields, you’ll need to make sure your form is publicly visible by visiting its "Edit" tab and checking "Published" under the "Publishing options" section.
Processing your Results
Once your users have had a chance to fill out your new webform, you'll want to take a look at the results. To do this:
- Visit the form.
- Click the "Results" tab.
- Underneath the "Results" tab, you should now see several options for accessing the submitted information.
- Under "Submissions", you can view each user's submission one-by-one.
- Under "Analysis", you can access basic statistical data about each question in your form, such as average response length, number of users who chose a particular option, etc.
- Under "Table", you can view all the responses at once in a single list.
- Under "Download", you can download an Excel-formatted spreadsheet containing all your user's responses, suitable for use in external statistical analysis.
- Finally, the "Clear" tab allows you to delete all previous submissions and start the survey over. Be very careful here, as you cannot undo this.
And that's it! There are quite a few things you can do with the Drupal webform module, and we hope this tutorial has given you a good headstart. If you have any questions or comments, please add a comment below; or, as always, you can submit a support request for more information.