Sending custom JSON data to the piwik.php tracking scripts doesn't work


I’m running piwik 0.4 and I would like to send custom data to piwik in order to track additional visitor data in piwik.

But when I try this (like it’s described in DOC) the page request isn’t tracked at all because of a JS Error.

The JS I’m using on test a page:
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + “piwik.php”, 1);
var myCustomObj = { “property1” : “value1” };
piwikTracker.setCustomVars( myCustomObj );
} catch( err ) {
var dbg=“ERROR.\n\n”;
dbg+="err: " + err+ “\n\n”;

The Error:

TypeError: piwikTracker.setCustomVars is not a function

Please help.

It’s pretty simple style_emoticons/<#EMO_DIR#>/rolleyes.gif style_emoticons/<#EMO_DIR#>/wink.gif

The function to use is named “setCustomData” and not “setCustomVars”.

This is just a misstake in the DOCs on (

var user = { ‘userId’ : user_id }; piwikTracker.setCustomVars( user );

Should be:

var user = { ‘userId’ : user_id }; piwikTracker.setCustomData( user );

Good catch.

i updated the docs ; vipsoft if you’d like access to the website we can discuss it :slight_smile:

FYI, I will be working on putting ‘Visitor custom variable’ in Piwik in the next release. Keep an eye on the ticket: Custom Variables support: new JS API and new reports · Issue #1984 · matomo-org/matomo · GitHub or the next release.