Collect User Surveys with a Drupal Webform

Download video

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.

Initial Setup

  1. screenshotWebform 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.
  2. screenshotIn the menu at the top of the screen, choose "Content management > Create content > Webform".
  3. screenshotYou 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).
  4. screenshotYou 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.
  5. screenshotIn 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.
  6. screenshotIf you'd like to receive users' form submissions via email, enter your email address in the "E-mail to address" field.
  7. screenshotWhen 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

  1. screenshotIn the "New component name" text field, enter "Email Address".
  2. screenshotIn 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).
  3. screenshotIf you check the "Value Mandatory" checkbox, users will be required to provide a value for this field before submitting the form.
  4. screenshotIf 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 to make sure you are in compliance with relevant university policies.
  5. screenshotClick the "Add" button.
  6. 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...
    1. screenshotIf you check "User email as default", Drupal will automatically fill in users' email addresses for them, provided they are logged in.
    2. screenshotThe "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.
    3. screenshotIf 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:

  1. screenshotWhen creating the field, choose "date" as its "Type".
  2. screenshotAs 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.

  1. screenshotIn this case, you'll want to choose "select" as the field type.
  2. screenshotOn the following page, enter the names of the professors into the "Options" field; each professor's name should be on its own line.
  3. screenshotWe 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.
  4. 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:

  1. Visit the form.
  2. Click the "Results" tab.
  3. Underneath the "Results" tab, you should now see several options for accessing the submitted information.
    1. Under "Submissions", you can view each user's submission one-by-one.
    2. 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.
    3. Under "Table", you can view all the responses at once in a single list.
    4. Under "Download", you can download an Excel-formatted spreadsheet containing all your user's responses, suitable for use in external statistical analysis.
    5. 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.


Your rating: None
riham's picture

add search to my webform results

HI i have a webform that collect data about doctors i want vistors of my website to search from doctor by name faculty university address etc. all this information is at the webform results but how to make the search only get results from the webform submissions not from all over the website thanks