Using Piwik 2.0-a11 from the Piwik Dev environment, I’m tracking some custom variables using the following code:
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://apache.piwik//";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
dvdsmpn.toInit(function ($) { // ####### this is essentially just a jQuery wrapper
_paq.push(['setCustomVariable', 1, 'username', dvdsmpn.params.remoteUser, 'visit']);
if (typeof dvdsmpn.params.spaceKey == 'string') {
_paq.push(['setCustomVariable', 2, 'space-key', dvdsmpn.params.spaceKey, 'page']);
}
if (typeof dvdsmpn.params.pageId == 'string') {
_paq.push(['setCustomVariable', 3, 'page-id', dvdsmpn.params.pageId, 'page']);
}
// The order is important: first setCustomVariable is called and then trackPageView records the request
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
});
</script>
<noscript><p><img src="http://apache.piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
This results in the following (selected) request parameters on piwik.php:
action_name:Welcome
...
url: http://dvdsmpsn-mbp.local/spaces/ds/Welcome
urlref: http://dvdsmpsn-mbp.local/dashboard
...
cvar: {"2":["space-key","ds"],"3":["page-id","98334"]}
...
_cvar: {"1":["username","admin"]}
...
I don’t see any of my custom variables appearing within the Piwik reporting interface under Visitors | Custom Variables
What am I doing wrong?