How can I get visitor ID from Piwik via JavaScript?


I tried this:


_paq.push([ function () { visitor_id = this.getVisitorId(); }]);
But these function don’t provide an actual ID that matches whatever’s on Piwik dashboard. Plus they change with every visit.

I have also tried to get that info from the cookie that Piwik stores _pk_id.2.89be

That didn’t work out so well though that if the cookies are cleared from the browser cache the visitor ID changes and my code breaks.

You can see the error message on one of the client sites here: