Familiarity with your users and their needs is the most
important aspect of any successful site or web campaign. Google Analytics is the perfect
tool to gather this sort of information. But there’s much more you can find out
about your users when you begin using custom variables to make better
decisions.
What is a Custom Variable?
A custom variable is a custom name-value pair that you can
assign to your visitors (or page views) using the JavaScript Tracking API, and
then visualize the reports of how many visits, conversions, etc. for each
custom variable.
A custom variable is defined by a name — for example, “User
status” — and a value – for example, “LoggedIn” or “Anonymous”. You can track up to 5 custom variables per visit
and/or up to 5 custom variables per page
view.
The important part of this definition is that you, as the
website owner, can define the segment that you want to apply to specific
visitors. The missing part of this definition is that you can apply it to your
visitors only after they actively do something on the site. For example, you
can define someone as a male or female only after he or she fills in that
information on the site. That may seem obvious, but it is important.
Custom
Variables Model & Configuration
The power of Custom Variables is partly due to its
hierarchy, the possibility to define whether the segment you are creating will
last only for the current page visited by a visitor, the current visit of a
visitor, or "to infinity ... and beyond!" (i.e. for as long as
visitors keep their cookies).
I will go over some examples below, but before it is
important to understand how Custom Variables are defined, their grammar. First,
as mentioned above, we can use different levels, meaning that the variable will
be saved for different periods of time:
Visitor Level —
this will modify the visitors' cookies for as long as they use the same browser
and device and do not erase cookies. As we will see below, we use this level to
keep unique information about a visitor, such as subscriptions, purchases, and
demographic characteristics provided by visitors in a form. A way to overcome
the limitation of multiple browsers and devices would be to update the
visitor's cookies every time he or she logs in to the website.
Session Level —
this modifies the visitors' cookies for the period of time during which the
visitor is active on the site. Very useful to track internal campaigns, such as
banners on the homepage.
Page Level — this
modifies the visitors' cookies for activity on a specific pageview or event.
Usually it will be used to group behavior in different sections of a website.
But before you start jumping out of joy, please note that if
you are using the free version of Google Analytics you have only 5 slots. That
means you have to think carefully before you implement them. If you are a lucky
person, and you have Google Analytics Premium, you will have 50 slots
available, which is a lot!
Custom Variables Configuretion:-
so you will need to
implement code in order to collect this data. Below is the code and the
explanation for each parameter:
_setCustomVar(index, name, value, opt_scope)
index (required) — The slot
for the custom variable, it can range from 1 - 5 for standard accounts or 1-50
for Premium accounts.
name (required) — The name
for the custom variable, a string that identifies the custom variable and
appears in the top-level Custom Variables report of the Analytics reports. For
example, if you are using a slot to track gender, the name would be 'Gender'.
value (required) — The value
for the custom variable, it appears in the table list of the UI for a selected
variable name. Typically, you will have two or more values for a given name.
Using the 'Gender' example above, the values would be either 'Male' or
'Female'.
opt_scope (optional) — The scope
for the custom variable. As described above, the scope defines the level of
user engagement with the site. It is a number whose possible values are 1
(visitor-level), 2 (session-level), or 3 (page-level). When left undefined, the
custom variable scope defaults to page-level interaction.
1.
_gaq.push(['._setCustomVar,
2.
1, // first slot
3.
'user-type', // custom variable name
4.
'visitor', // custom variable value
5.
2 // custom variable scope - session-level
6. ]);