Understand your customers by bringing all of your data together so everyone in your organization can explore, gain intelligence and inform strategies to increase business performance. Learn more.
So, what is “User-Defined?"
The user defined variable allows you to "label" a visitor if they complete a certain action on your site, such as making a purchase or visiting a key page. These labels are useful because they last across multiple visits to your site.
These labels are often called Custom Segments (or Custom Segmentation). You can see the data from these Custom Segments in the User Defined report, which is the last report of the Visitors section in Google Analytics.
How do I add these “labels” to my website visitors?
Making use of the User-Defined report in Google Analytics requires a bit of extra coding help from your IT department or webmaster, but it’s often well worth the effort.
For example, let’s say that I want to add a label of “customers” to any visitor who reaches my shopping cart’s receipt page. In order to do this, I would add an additional line of code to the Google Analytics Tracking Code (GATC) on my receipt page. It would then look something like this:
Notice the line in bold that includes _setVar. When this is present on a page within the Google Analytics Tracking Code, an additional cookie (called the __utmv cookie) gets set on a visitor’s computer, with its sole purpose being to identify the visitor by the label (or value) that you used in the code. If you take a look at the code example above, you will see that I used the term “customers,“ the label that I want to appear in the User Defined report.
Now, on their next visit to the site, they will be identified as a part of the “customers” segment in the User Defined report, allowing you to perform analysis on all visitors who have purchased something from your online store. Neat, huh?
Can I use _setVar when someone clicks on a link instead of visiting a page?
Yes - you can also use the pageTracker._setVar function when someone clicks on an important link on your site, or makes a key selection on an important form that you want visitors to fill out. For example, if you wanted to add a custom label to any visitor who clicks on your “Live Help” applet, you can ask your IT department or webmaster to add an “onClick” event, and give them the following line of code:
What will this look like in the end?
When all of your coding is complete, check the User Defined report after about a day or so and you should see something like this:
After the data has been collected by Google Analytics, you can interact with it just like you would with any other report. Click on the “Goal Conversion” tab directly above the table to see how many customers have reached key pages of your site, or use the dimensioning feature to see what sources of traffic were responsible for bringing these special visitors to your website!
Are there any other ways to use _setVar?
One neat usage of the _setVar function is to use it to exclude your own traffic from reports when using a dynamic IP address. For example, let’s say that you wanted to exclude your entire company’s traffic from appearing in reports, and your company uses dynamic IP addresses.
Because it would be nearly impossible to write a filter to exclude traffic from a dynamic IP address, you can create an HTML page that is not a part of your website and add Google Analytics Tracking Code with the call to _setVar and a label of “employees” (or something similar).
Next, you can ask each employee to visit that page from their browser of choice – this will drop a cookie on their computer, identifying them as “employees.” Finally, you can then apply a filter with the following specifications to your profile, and your internal traffic will be excluded:
Some technical notes about Custom Segmentation:
A full, technical explanation of _setVar and the User-Defined Report can be found here.
The User Defined report in Google Analytics is a great place to start segmenting your traffic. With a little bit of help from your IT department, you can not only begin to collect awesome data, but you can also begin to gain advanced knowledge about what makes your VIP website visitors register, sign-up for your newsletter, or purchase something from your online store. This will definitely help you become that Analysis Ninja that Avinash Kaushik loves to talk about!
Written by Joe Teixeira of MoreVisibility, a Google Analytics Authorized Consultant.