How to add customData in trackGoal function


#1

In piwik/js/piwik.js the trackGoal function is defined as


trackGoal: function (idGoal, customRevenue, customData)

Could someone please give a short example of how to use this function in JS with all three parameters?

Where would this customData be shown in Piwik and in which db field would it be stored?

The following calls have already been tested but didn’t seem to be successful as no data was shown in Piwik interface.


piwikTracker.trackGoal(1, 10.00, "orderno");
piwikTracker.trackGoal(1, 10.00, "orderno=12345");
piwikTracker.trackGoal(1, 10.00, "orderno", "12345");
piwikTracker.trackGoal(1, 10.00, 'orderno=12345');
piwikTracker.trackGoal(1, 10.00, 'orderno', '12345');


(Matthieu Aubry) #2

You can use Custom Variables: Custom Variables Analytics - Analytics Platform - Matomo

For Goal conversions, what happens is that the Custom Variables are copied in the conversion and then reported in the Goals report under Custom Variables.

Note: in the doc page, ignore the “scope” things, since this is new and the code not yet published (we updated documentation a bit too early)


#3

Thanks for your answer matt,

so the trackGoal method will not (yet?) work with those three parameters? The setCustomVariable method has to be used instead but the custom data will still be displayed in goals view? Did I get this correct?

regards,
Chris


(vipsoft) #4

customData and customVariables are separate; customVariables are displayed in the goals view

customData is used by some plugins (e.g., Community/Demographics) and the testing framework


#5

Ok, so customData won’t be displayed in Piwik frontend by default? Nevertheless, could you please give a short example of how to use customData in conjunction with the trackGoal function? Where would this customData be stored?


(vipsoft) #6

customData isn’t stored anywhere by Piwik; this is for plugins to use and Goals isn’t one of them