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 method to collect ...

Get Web Site Measurement Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.