Periscopix

“I have the body of an 18 year old. I keep it in the fridge.”

Spike Milligan

Simon Norris

Read bio

Today: User Defined Variables

GA allows a single user defined variable (UDV) to be sent to the system when a user is browsing a site. You can use this to create custom filters and segments that split your users into distinct groups, to tell you more about behaviour patterns.

When you visit a site that uses GA the javascript stores several cookies on your computer. These contain information like what site you came from, what the capabilities of your browser are, where you are in the world, etc. They also are used specifically by GA to store data about you, like whether you’ve visited the site before and when.

There is one other cookie that is not used by default, and that stores a variable that you can define. In your javascript code you can use the ._SetVar() function to define that variable. It can be anything you like, and you can set it anywhere you like. You can then see the results in the “User Defined” report.

On its own, this is of limited use. You could perhaps set the variable equal to “goal completed” on the thank-you page of a form. But you can track this stuff already in GA very effectively. So why do we want to use it?

Filters

Advanced filters in GA allow you to take any variable that is being sent to GA, manipulate it, and add it to another variable. One popular use of this ability (credit to Brian Clifton for this) is to capture previous referrer data and add it to newest referrer data.

Generally in GA when you look at the source and medium a visitor came from you will only see the most recent way they got to your site. Every time they arrive (except directly) their referral information will be overwritten. So you might have a user who visits your site once from your PPC campaign, visits again by searching on your brand and coming through the organic searches, and then buying something. You want to credit the PPC campaign with that sale, right? In GA they would be classed as an organic visitor and that sale would be credited to brand searches.

So how do UDVs help us here? Let’s say that you adapt your javascript code to read from the referral cookie when they arrive at your site. You store the source and medium in the UDV in this format: ._SetVar(source|medium). You will then see that information in your user defined report. However the clever bit is when we combine this with advanced filters. Let’s say we take the first portion (source) and append it to GA’s own “source” variable. We set it up so that we now see source reported as: “new_source, old_source”. This is very powerful, because now we can see not only how the user found your site to make the purchase, but how they found your site the first time - how they became aware of you and which of your advertising streams - ppc, email shots, affiliates - has been the most effective at finding you new customers.

Advanced Segments

Advanced segments let you look at only data where a specific test is true, or not true, or any other combination of logical results for any number of tests. So for instance, if a user clicks large orange “discounts here!” button on your site, set the UDV to “button_clicked”. From then on, that cookie stays associated with that user for all their subsequent visits to your site. You set an advanced segment so that you see only data where the UDV is set to “button_clicked”. Create another one for UDV not equal to “button_clicked”. Now when you view your report with both of these segments enabled, you’ll see the different stats

between users who clicked the button and users who didn’t. Did the button work? Did users who clicked the button stay on the site longer? Did they complete more goals? And crucially, you can also see what type of users did or didn’t complete the action. Did users from one demographic never click? Why not? Did no users with Firefox click? Maybe there’s a technical problem showing the button in that browser.

The power of being able to set a UDV on specific actions is very useful. Because it means you can choose any way you like of segmenting your data, and segmenting your data is vital if you want to see useful stats about your users. If you want to compare one group against another, if you want to see what type of person completes an action, if you want to be able to look at past customers behaviour separately from those who have never bought from you (and compare between them)… The list goes on. What’s the upshot of all this?

End Results

All these are just scratching the surface of what you can do with a user defined variable. You only get one - so use it wisely! There is potential to put several pieces of information into the variable, with some kind of delimiter. You can add a new term each time a user completes a specific action, then in your advanced filters you can create separate ones depending if the UDV contains the specific information.

You need to have some familiarity with the ga.js code and some basic javascript to be able to pull these off with a high degree of sophistication, but there are plenty of forums around that will help you with this, if you have it clear in your mind what you want to do.

So now get thinking: what can you come up with? What would be most useful to be able to see in your reports? How would you like to segment your visitors and how could you use the UDV to do this?

Answers on a postcard, please.

View part two of this series here.

  • del.icio.us
  • Digg
  • Facebook
  • Reddit
  • StumbleUpon
  • Twitter

Related articles & content

Back to blog articles

Pulley!