For traffic segmentation, Google Analytics has such a great
_setCustomVar method.
Method signature:
_setCustomVar (index, name, value, opt_scope)
index - slot, there are 5 such slots (from 1 to 5). The variable must be placed in one of the slots.
name is the name of the variable.
value is the value of the variable.
opt_scope - variable context: 1 (visitor-level), 2 (session-level), 3 (page-level).
- visitor-level - Lifetime is eternal. It is useful to establish for the visitor once and for all (for example, for registered visitors or for buyers).
- session-level - Timeout - session. Convenient for separating authorized and anonymous site visitors.
- page-level — Used to track events or specific page views.
My examples of using this method are:
- 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
);
I use this segment to track the behavior of registered visitors.
- pageTracker._setCustomVar (
2, // This custom var is set to slot # 2
"User", // The name of the custom variable
"$ username", // Sets the value of "User" to "$ username" depending on current visitor
2 // Sets the scope to visitor-level
);
and this segment to track the behavior of a specific authorized user.
The main problem arises in the allocation of the created segments in the Google Analytics panel, since currently, they are not visible in standard reports.
')
In order to select, for example, a segment of all registered visitors, you must create a new segment. For this:
- Go to the link " Segments with advanced settings " in the " My Settings " block in the left GA menu.
- Click on the link " + Create a new user segment ."
- From the " Sizes -> Visitors " list, drag the " Custom Variable (Value 1) " to the " value or metric " block.
- Select the condition " exact match " value " Registered ".
- Set the name " Registered Visitors " for the segment.
- Click the " Create Segment " button.
The segment has been created; now it can be selected on any report. To do this, simply select "
Segments with advanced settings " above the date interval and select the created segment in the "
Custom Segments " list.
For the second segment (tracking authorized users) it is convenient to create a custom report.
- To do this, go to " My Settings -> Custom Reports -> + Create a new custom report ."
- Next, drag the required indicators into blocks " indicator ".
- Drag the " Custom Variable (Key 2) " indicator from the " Dimensions -> Visitors " list to the measurement block.
- In the nested dimension we drag the indicator " Custom Variable (Value 2) " also from the list " Sizes -> Visitors ".
- Save the report.
Now this report can be viewed in custom reports. When we just go into this user report, we see general statistics for all authorized users, and if we go to the next level (in our case, the User variable (Custom Variable (Key 2))), we will see statistics for each authorized user.
These are my examples of real use.
You can also read a detailed
manual from Google on custom variables.
Thanks for attention!