setCustomVariable if not set


as I understand each call to setCustomVariable overwrites the previous setting .

Is it possible to make the value of setCustomVariable persistent or to do setCustomVariableIfNotSet

I’m aware of the scope=visit parameter, however as far as I understand this does not prevent overwriting the existing value.

Seen some example’s pushing functions but I can’t get it to work.

_pag.push { function

if not custom variable {
 setCustomVariable [..];

actual goal is to set up simpel A/B testing, later on the page will be some code like

switch CustomVariable
  case 1 : write some css;
  case 2 : write other css;

any other suggestions how to set up A/B testing with piwik are welcome of course

ive been having this problem aswell.


We have released a plugin that works on top of Piwik to run A/B Tests, Split Tests, Experiments see . A full list of features is mentioned on the Marketplace at

It lets you easily run experiments on websites, servers, apps and in campaigns and has lots of features to customize your experiment and to define your success and your expectations for an experiment to increases your sales, revenue, conversions, pageviews, and more.

More docs are available at: User Guides, FAQ, Developer docs