SiteExperts.com Logo Home | Community | Developer's Paradise | Jobs
User Groups | Site Tools | Site Information | Search

Inside Technique : Popup Surveys
By Scott Isaacs

In this article, we show you how to create a pop-up survey window like the one displayed when you entered this page. In this technique, we show you how to popup a survey window as the page is being downloaded. While the user is waiting for the page to download the survey popup enables web-designers to quickly ask simple questions. The survey window is also a way to interact with the user during the download period.

We had the following goals when we created this survey:

  1. Make sure the survey displays as soon as possible.
  2. Only ask 1 multiple choice question. We want our surveys to be as simple and easy to use as possible.
  3. After answering the question, immediately close the survey window.
  4. Only pop-up a specific survey once.
  5. Make it easy to tag surveys so when new surveys are made, the pop-up window appears again.

To solve the first goal, we embed the survey script on the page before the document's contents are reached. In addition, the survey is completely self-contained in the script. This allows the survey to be displayed without requiring an additional round-trip.

The second goal is a style decision. By generalizing the survey to a multiple choice question, we are able to write a generic routine for generating the survey. This also makes it possible to build surveys that randomly choose from multiple questions. Why we made this decision becomes more apparent when we walk you through the code.

The last goals are also about user experience. Each survey question should only display once so the user is not asked the same question over and over again. Not only can this skew your survey, but it creates a poor user experience. To track if the user responded to the survey, a small cookie is stored on their machine. This cookie is tied to a specific question. This ensures any new surveys will be provided to the user. For example, if you answered the pop-up survey, try refreshing this page. The survey should not be displayed again.

Next we take you through both the client-side script for generating the survey, and the server-side ASP script for processing the survey results. First we start with the client-side script.