You may have noticed the menu items called User Var 1, User Var 2 (and so on) in the Confetti, overlay views of your reports or Recordings. 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.
These variables are purposely left undefined so you can fill them with custom data. For example, you could track clicks by logged-in users vs. clicks by unregistered visitors or segment your visitors’ clicks by the number of previous clicks they made on the page. With a little Javascript code, you can categorize clicks on your pages in any way you want.
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)
You set the value of a user variable with the CE2.set Javascript function:
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.
(window.CE_API || (window.CE_API = [])).push(function(){ 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. Each click in the sample code below will have User 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 the clicked button:
<script type="text/javascript"> (window.CE_API || (window.CE_API = [])).push(function(){ CE2.set(1, "initial value"); }); </script> <a href="javascript:void(CE2 && CE2.set(1, 'clicked link'))"> link </a>