Sign in

Analytics Help



How can I classify my visitors according to what pages they visit on my site or what their responses on a form are?

Print
Note: This article is for the latest version of the tracking code. If you are using the older version, please read the following article.

To determine which tracking code you are using, please see Which version of the tracking code am I using?

In addition to segmenting users along pre-defined segments such as geographic region and language preference, Google Analytics allows you to define custom segments and analyze the behavior of each segment. For example, you might ask visitors to select their job category (such as Engineering, Marketing, motorcycle stunt riding, etc) from a form. You could then analyze browsing and buying behavior based upon the selected job categories.

You can view conversion behavior for each of your custom segments from the Visitors Overview report. Click the User Defined link, then select the Goal Conversion tab.

To set a visitor segment, simply call the JavaScript _setVar function. For example, make the following call anywhere on the web page below your tracking code:

<script type="text/javascript">pageTracker._setVar('Marketing/PR');</script>

Examples:

Assign visitors to a particular page to the "Marketing/PR" segment

In this example, anyone who visits the page will be assigned to the "Marketing/PR" segment.

<body onLoad="javascript:pageTracker._setVar('Marketing/PR');">

Assign users to a segment when a link is clicked

<a href="link.html" onClick="pageTracker._setVar('Marketing/PR');">Click here</a>

Assign visitors to a segment based on their form selection

In this example, visitors are assigned to a segment according to their selection in a form.

<form onSubmit="pageTracker._setVar(this.mymenu.options
[this.mymenu.selectedIndex].value);">
<select name=mymenu>
<option value="Technical/Engineering">
Technical/Engineering</option>
<option value="Marketing/PR">Marketing/PR</option>
<option value="Manufacturing">Manufacturing</option>
<option value="General Management">General Management</option>

Was this information helpful?

Learn from other users

Find answers, ask questions, and share your expertise with others in the Analytics help forum.

Tell us how we're doing: Please answer a few questions about your experience to help us improve our Help Center.