Custom variable usage

I’m currently using custom variables for 2 different purposes:
[li] Present comparative statistics between custom variable values via the “Custom variables” Widget (the few informations presented are sufficient for me). For example, I use a “Visitor language” to compare how much visitors are visiting the english or french part of my sites
[/li][li] Segment the statistics showed. For example, I have a custom variable named “context_id” that save the id of the context (this is a custom notion), then I can use something like


when invoking widgets (iframed) to present subsets of visits.

My first problem is that I can’t hide “segment purpose custom variables” from “Custom variables” widget. Indeed, I don’t want my customer to see them. This is not the objective.
Can I hide some custom variable from “Custom variables” widget in any way ? If not, can you give me some lead on how to do it ?

My second problem is the number of custom variables available: 5 will not be enough for my purposes. Is there a performance reason for this restriction ? Could it be possible to add more ?

  1. it is not possible to hide some variables at present, but one could write a custom plugin that would call the ‘getCustomVariables’ API and remove the lines that you don’t want to display, still using the standard getCustomVariables calls in the API where you need the other variables

  2. this is in the DB schema, we could add more but it is not planned

Thank you Matt for your answers

  1. Ok, I will try to create this custom plugin
  2. I didn’t entered deeply in the code yet. Do you think add more will impact significantly on performance ? Is it hard to add more by myself ( keeping aside the obvious upgradability problems ) ?

A strict hardcoded limit of 5 was a bad idea. Many marketers use more than 5 variables.

I am also interested to know how to add more variables. I don’t even need a ton, but a couple more would do.

It’s not configureable at the moment (because it affects the database schema).

You are, however, welcome to customize it. Look for:

  • custom_var_k* and custom_var_v* in piwik/core/Db/Schema/Myisam.php (log_visit and log_conversion tables) to figure out where to add new columns
  • MAX_CUSTOM_VARIABLES in piwik/core/Tracker.php
  • maxCustomVariables in piwik/js/piwik.js (note: this is in the unminified source of the next release)

Happy New Year! If you are still using Piwik and interested in the awesome new feature of “Creating a Custom Segment in Piwik and apply to reports in Real time!” we need YOUR help, with a little or big donation at:

This will allow to dynamically add or edit, a new set of rules for example “Show all visitors from USA and using Firefox and using Google”. This will be done via a simple to use interface. See screenshots and more info here:

We are crowd funding the future of Piwik and this feature in particular. With your help we can do it.