As you probably already know, Google Analytics has been updated not so long ago. This update was highlighted here, in Habré, -
Google Analytics grand updateIn particular, the changes affected:
- Increased the number of goals to 20 (4 sets of 5 goals each)
- Appeared goals of new types (time spent on the site and the number of pages viewed)
- Web analytics mobile sites. Statistics from applications on Android and IPhone platforms as well as for website
- Adapt Analytics code for selected platform
- The appearance of the Pivot tables in the reports - something that many missed, and because of what they had to use Excel
- Filter data in reports on the fly
- Added new metric - unique visitors
- Expanded opportunity to work with events
- Completely changed the principles of working with user variables
At last I would like to stop my attention.
For a long time, the only method provided by GA to segment its traffic in statistics was the
_setVar () function . With the help of this function, it was possible to set a user variable (only one!) And thus assign the user to a specific category. It looked something like this:
')
pageTracker._setVar(”registered”);
pageTracker._trackPageview();
Say, the code above could be on the page thankyou_for_registration.html and here we establish that the user has registered on the site in order to continue to track separately exclusively the behavior of registered users on the site.
You can do this in the section Visitors-> User-Defined
How it worked:
When the variable was set, an additional cookie was set for the user
__utmv , the value of which was assigned the name of the variable from the function _setVar, i.e. in our case: ”registered”. This cookie was set for a duration of 2 years.
In the future, getting this cookie Analytics believed that the user belongs to the segment of registered users on the site.
In some cases this was enough, for example, if you wanted to sigmentate on a gender sign, whether the user is registered or not, whether you already made a purchase. But if you wanted to add several such filters, then everything went awry, because if the user already had this cookie set, say, to “registered”, and after that he filled out info about himself in the profile and indicated his gender, and we called again the pageTracker._setVar (”male”); then the call to this function overwritten the previous set value (”registered”).
Thus, GA only saved the last value of the variable recorded in the __utmv cookie.
There was also a partial solution to this problem, about which you can read by clicking on this
link.The main idea of ​​this solution is: do not overwrite the variables in __utmv cookies, but to supplement the current value of the variable with a new one (concatenate the new label to the one already installed)
For example, after consecutive calls:
pageTracker._setVar ("male");
pageTracker._setVar (”registered”);
In reality, we will only have data that the user is “registered”
Using the concatenation method:
superSetVar ('/ male');
superSetVar ('/ registered');
We will create a variable / male / registered which will reflect the composite meaning of our segmentation.
But there was still the problem of counting such important criteria as bounce rate and time on site, namely, they were very much changed bounce rate - grew, time on site - fell. This happened because after setting the _setVar variable, the visit was considered new.
All this together led to the fact that after updating GA the _setVar method became
deprecatedAnd what appeared instead of him?
And there appeared, actually the method
__setCustomVarThe signature of this method is as follows:
_setCustomVar (index, name, value, opt_scope)
In addition to the variable name (name) and value (value), 2 more interesting parameters appeared here.
opt_scope : there are 3 contexts of variables: 1 (visitor-level), 2 (session-level), 3 (page-level).
- visitor-level - Lifetime is eternal. It is useful when it is put to the user once and for all (for example, gender, registered or not, made a purchase, is it a VIP user (client)).
- session-level - The lifetime of the session. It is useful, for example, for tracking users who are logged in and anonymous users.
- page-level — Used to track events or specific page views.
index - slot. There are 5 slots (from 1 to 5). The variable must be placed in one of the slots.
I will not go further into the details, because There is a very good
manual from Google for custom variables . True to English. There are examples and described in detail what, how and why.
I will give an example of how I use it.
For example, for segmentation by sex and whether the user is registered, on the first page after registration (that is thankyou_for_registration.html) I add
pageTracker._setCustomVar(
1, // This custom var is set to slot #1
"Users", // The name of the custom variable
"Registered", // Sets the value of "Users" var
1 // Sets the scope to visitor-level
);
pageTracker._setCustomVar(
2, // This custom var is set to slot #2
"Gender", // The name of the custom variable
"$Gender", // Sets the value of "Gender" to "Male" or "Female" depending on field in registration form
1 // Sets the scope to visitor-level
);
pageTracker._trackPageview();
When using different Osprey you need to be extremely careful that the variables do not overwrite each other. You can also read about it
here.In this article I just told what tools I use for traffic segmentation, I will be glad to hear what you use :-)