setCustomVariable not working


#1

I use piwik to track my web page visits and it works fine. I just added this code to the javascript on my page:


var _paq = _paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "mypiwiklink";
        _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);
       })();
      // end piwik track code

This code has no problem. It is standard. And I see the page visits on piwik dashboard, as expected. Now I would like to add a custom variable to the same web page, that tracks each call of specific function on my page. So inside the code of the function, which call I would like to track, I’ve added:


var selectTableRowHandler = function() {

        // function code

        //piwik code inside the function code:

                                 var _paq = _paq || [];
                                _paq.push(['setCustomVariable',  
                                    1, 
                                    "Visitor",
                                    "myfile", 
                                    "page" 
                                    ]);
                                  _paq.push(['trackPageView']);
                                  _paq.push(['enableLinkTracking']);
                                  (function() {
                                    var u=(("https:" == document.location.protocol) ? "https" : "http") + "mypiwiklink";
                                    _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);
                                  })();


     // end of function code here
}

When I debug, I see that the code is executed without errors, but I can’t see any custom varibales added at the piwik dashboard. What am I doing wrong? Thanks!