Published: Tuesday, July 17, 2001
Determining How Long Your Users Spend Filling Out Forms
By Scott Mitchell
Introduction
Have you ever wondered how long one of your visitors spends filling out a particular form? Such
information is vital for companies that conduct business on the Internet. Imagine if everytime
you wanted to buy a book from Amazon.com you had to spend 60 seconds filling out a form with
billing and shipping information - do you think you'd buy many books from Amazon.com in such
a situation?
From a usability standpoint, it would be nice to be able to determine how long each visitor spent
filling out a form on your Web site. Armed with that data, you could then focus on those forms that
take longer to fill out and take steps to reduce the time needed to complete those forms. Once
you've made those changes, you could compare the old time values with the new time values for filling
out the form to determine whether or not your changes to the form increased your users' efficiency
in filling out the form.
So How Do I Determine How Long a User Spends Filling Out a Form?
The simplest way to determine the length a user spends filling out a form is to add a hidden
form field to the form that records the current time. When the form is submitted, you can then
use the VBScript function DateDiff to calculate the number of seconds elapsed from
the hidden form field and the current time.
The first step is to place a hidden form field in our form that contains the current
date/time. This is easily accomplished with the following code:
<form method="formMethod" action="URLtoRedirectToWhenTheFormIsSubmitted">
...
<input type="hidden" name="tmrTimeStarted" value="<%=Now()%>">
</form>
|
When the user visits this ASP page, the Now() function returns the current date/time.
Now, in the ASP page that the form redirects to (that is, the ASP page in the form's
action attribute), we need to retrieve the time in the hidden variable and
calculate how many seconds have elapsed since the current time. This can be done in one line
of code, using the DateDiff function:
Dim tmrTotalTimeSpent
tmrTotalTimeSpent = DateDiff("s", Request("tmrTimeStarted"), Now())
|
[
View the live demo!]
The DateDiff function's first parameter identifies what date interval to return.
For this instance, we use "s", meaning we are interested in the number of elapsed
seconds. DateDiff then finds the number of elapsed seconds between the last parameter
(the current date/time, Now()) and the second parameter (the time the user first visited
the form page). (For more information on DateDiff be sure to read
this article.)
Once you have this elapsed value, you can do with it what you please. In this article's
live demo the time is simply outputted, but a more
useful approach would be to log the value in a database. Once you had a number of data points
you could start analyzing the data and look at ways to reduce the time spent on filling out forms
(if needed).
A Major Caveat
Do realize that this method is in no way guaranteed to be an accurate measurement of the actual
time spent by the user working on the form. This uncertainty is due to the Web's stateless
nature. Imagine that a visitor loaded up a Web page with a form with every intent on filling out
the form. At the time the page is requested, the hidden form variable is inserted into the form
recording the time the page was loaded. Great. Now, what happens if the user gets midway through
filling out the form and then must leave for a meeting? Or for her lunch break? When she comes back
and finishes filling out the form, the time spent filling out the form will be grotesquely out of
whack. While it may have taken this fictional user only 15 seconds to fill out the form, if
she went to an hour lunch, our code would report that it took her over 3,600 seconds! Eeek!
Additionally, if a user just enters junk fields, the time it takes him to complete the form would
be far less than what it would take for someone who is seriously filling out the form.
For these reasons, it would be wise when analyzing the data to discard any samples that seemed to
take the user a very long or very short time to complete the form.
Conclusion
If you are looking for a quick and easy way to get a decent view at how long users are taking
to fill out forms on your Web site, this simple approach may be perfect for you. Note that to
take full advantage of this time recording system, you'd need to log the time results for each
Web page that used a form in a database somewhere. Then, after enough data had accumulated, you
could effectively analyze this data and then work at reducing the time spent on those form pages
that have the highest time spent on them.
Happy Programming!
By Scott Mitchell