About custom variables in Analytics
Piwik PRO gathers a great deal of data about each of your website visitor. However it only gathers data that is standard and commonly accessible. In order to track any additional information you’ll need to set it up first. One of the possibilities of sending such data are custom variables.
First thing we need to decide about our new Custom Variable is its scope. The scope is often a confusing term so I’ll try to explain it here. There are two scopes:
The scope decides what the custom variable will represent.
In case of the page scope the variable is attached to the Page view, showing additional info about the single view. It can, for example, represent the language in which the page was displayed. Or maybe your pages have some categories that are not represented in the URL or Page Title but still you would like to know about them. A more technical use case is checking which server has actually served the page in case of the load-balanced cluster.
The visit scope attaches additional information to the current visit. Let’s say your website is a clothes shop. Your visitors log in and leave a lot of info about themselves that is not tracked by default. Their sizes, their names, their gender etc. All of those parameters can be tracked as a custom variable in the scope of visit. Or maybe you track intranet website for thousands of employees. You can attach the custom variable to them representing their job title, the location of their work or their department.
It’s important to know that the visit custom variables stores the information in a first party cookie which expires at the end of the visit so if the same visitor visits your page again after a while his variables will be empty and will have to be set again.
Of course there are plenty of other uses for this feature so feel free to think of your own!
Number of custom variables
Custom variables are limited as each of them is represented by additional column in the database. By default Piwik PRO Cloud accounts have 10 custom variables from each scope. If you would like to raise the amount of the variables just let our support team know and they will coordinate the change for you.
Track variables with Tag Manager
Piwik PRO Tag Manager makes it almost effortless to add a custom variable of any scope to the tracker.
Simply open your standard Piwik PRO tag in your Tag Managers Tag tab
Scroll down until you’ll see “+ Track Piwik Custom Variables for this visitor” button, click it.
You’ll see the Variable edition window. first of all you need to select the slot (from the initial 10) that the Variable will occupy. If it’s the first Custom Variable you’re going to track just type 1.
Next you’ll need to name your variable. Choose any name you like.
In the third field you’ll need to pass the actual value that you want to record. This is a great place to use Piwik PRO Tag Manager Variables feature:
These are different variables than the Piwik PRO Custom Variables so please do not confuse them. You’ll need to create a PPTM Variable that will retrieve the needed information from your website and pass it to the Analytics. In order to use the variable here, just click the (x) button next to the third field and choose it from the list.
After choosing the right variable, just hit the Save button and Publish button afterwards and you’re all set. Your new visits will come equipped with a custom Variable.
You can check and use the variables values in many places across the PPMS.
In Analytics they can be found under Visitors report category
Every Variable attached to the visitor will also be visible next to his profile in the Visitor Log.