O'Reilly logo

Web Site Measurement Hacks by Eric T. Peterson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hack #77. Track Demographic Data Using Custom Variables and Visitor Segmentation

If you're collecting any type of demographic data from your visitors using forms, you can easily pass this information along to your measurement application and do some light demographic analysis.

It is very common for sites that require registration to ask a few questions about demographics in the process of signing a visitor up for a service (Figure 5-16).

The most typical questions are, "What is your gender?" and, "When were you born?" but occasionally sites ask for other information, such as annual income, marital status, or whether you have children. Fortunately for you, since this information is nearly always collected via an HTML form, the results can easily be passed to your web measurement system and collected into custom variables [Hack #31] or used to create visitor segments [Hack #48] .

Subscription form with demographic data

Figure 5-16. Subscription form with demographic data

How to Pass Demographic Data to Your Measurement Application

For the most part, forms like the one in Figure 5-16 use the form POST method in HTTP to hide the fields and values from prying eyes, a good idea when you're asking for personal information. If this is the case, you'll have to use some server-side code to grab the information from the form processing script and pass it to your measurement application.

For example, the following form uses the POST

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required