How Do I Set The Values Of User Var 1, User Var 2, Etc. In The Confetti And Overlay Views?

You may have noticed the menu items called User Var 1, User Var 2 (and so on) in the confetti and overlay views of your reports. By default, no data is attached to these menu options. If you were to select User Var 1 from one of your own reports, you'd see that every click on confetti under that option is marked Unknown.

CE2.set

You set the value of a user variable with the CE2.set Javascript function:

CE2.set(userVar, value)
userVar: A number from 1 to 5
value: Any string value (it may be truncated if it is over 100 characters)

Example: CE2.set(1, 'some string');

Any clicks on the page will include the custom values you specified with CE2.set. Those values will appear in the confetti and overlay views of your reports.

You are not restricted to just calling set once, of course. You could fill up all 5 user vars:

function CE_READY() {
  CE2.set(1, 'some string');
  CE2.set(2, 'another value');
  CE2.set(3, 'yet another value');
  CE2.set(4, 'more');
  CE2.set(5, 'and more');
}

You can also change a variable after it was initially set. In the sample code below, each click will haveUser Var 1 set to initial value. However, after a visitor clicks the image button.png, any subsequent clicks on that page will have User Var 1 set to clicked button:

<script type="text/javascript">
  function CE_READY() {
    CE2.set(1, "initial value");
  }
</script>
<a href="nojavascript...void(CE2 && CE2.set(1, 'clicked link'))"> link </a>

Using CE_READY

As soon as Crazy Egg is initialized, it calls the Javascript function CE_READY, if it has been defined. Like the above examples, you should define a function named CE_READY and put your custom Crazy Egg code inside. This ensures that your code does not try to use the CE2 object before it has been defined, which would cause errors that would prevent your custom variables from being tracked.