As always with Google Analytics, it's only when you start using the more advanced and hidden away features such as custom variables do you really start to get true value out of it. Although we can analyse and learn a lot from the data presented by default, in order to further segment and understand, we need to employ custom variables.
Consider this, if you wanted to know how your premium members acted on your site compared to your free members, how would you find out in Google Analytics? The solution is simple, you'd set a custom variable. With one simple additional line of code in our tracking script, we can make Analytics far more powerful and actionable as we shall explore below.
What Are Custom Variables & Why Should I Care?
Custom variables are just another way for us to tag our data so that we can segment it in more actionable ways. Although the default tracking in Analytics is good, is usually requires a helping hand to get at the data we really care about. By setting up custom variables in our membership example above, we now have a whole new way to see how various user groups interact with our websites.
With careful analysis, we may realise that our premium users aren't spending as much time as we thought on the website interacting or perhaps we find that a large number of them visit the help section regularly. A simple but powerful realisation that may have been lost in the noise of the collective dataset otherwise.
Setting Up Custom Variables
Setting up custom variables can be tricky for most websites and can require some fore planning on the best way to implement, if you use a pre-built solution then you may find it hard to implement the custom variable script on the relevant pages however the best place to start is by reading the documents:
The basic script works in a very similar way to the event tracking script; it's one line where you pass an ID, a name for the variable, a value for the variable and the scope of the variable which is optional:
_setCustomVar(index, name, value, opt_scope)
You can also set up to 5 different custom variables on a page
As we can see in the picture above, Moz is using a custom variable to track my user type which when logged in shows up as "pro". This changes back to "visitor" when I'm logged out.
Finding Custom Variables In The Interface
You can find the default stats for any of your custom variables by going to Audience -> Custom -> Custom Variables however you will find most value with custom variables by using them to filter and segment other screens or including them in your Advanced Segments/Custom Reports.
Where You Could Use Custom Variables
So long as you don't send personally identifiable information to Google then you can use custom variables for literally anything you can think of. Some great things to potentially track are:
- Track customers who purchase multiple times.
- Track those who socially share.
- Those who have subscribed to RSS feeds or newsletters.
- Track those who have interacted by submitting comments.
- Track those who have sent contact forms.
- Track those who visit sections a lot such as help section.
- Track different levels of membership such as pro and free members.
- Track those who have used discount codes or special offers.
- Track certain sections of your website such as category pages or product ranges.
These are some potential ideas on what to track, each one when combined with other data will give you helpful insights into how your visitors are interacting with your website.
For more ideas check out 10 Things To Track Using Google Analytics Custom Variables
Some Very Important Things To Bear In Mind
Custom variables are not without their own quirks. If they are not set up correctly, you can have unusual data corruption and because they offer three levels of scope, it's very easy to incorrectly set up them up. As always, accuracy of data is paramount so it's very important to understand how these variables have been implemented.
Again, I'd strongly suggest studying the official documentation to truly understand the code and implications.
Placement of the code, length of the variable name & value and overwriting are all other things to consider when creating your variables.
It's important to remember that custom variables aren't always the correct tool for the job either - before implementing any, consider for example, if event tracking would be a quicker and more effective way to track various data. If you want to know how many people click the add to cart button then this may be a much better way of obtaining that data.
Custom variables are very powerful but only as powerful as those who set them up and analyse the data.
Got ideas on how to use custom variables? I'd love to know about them in the comments below!