@tsteur opened this Issue on December 3rd 2016 Owner

By default tracking is done like this: _paq.push(['trackFooBar', 'param1', 'param2]).

When working with multiple trackers (and tracking different data to different sites) the same would be

var tracker = Piwik.getAsyncTracker(piwikUrl, siteId);
tracker.trackFooBar('param1', 'param2');

I think it would be more consistent to always use a push method as well instead:

var tracker = Piwik.getAsyncTracker(piwikUrl, siteId);
tracker.push(['trackFooBar', 'param1', 'param2']);

This simplifies some docs greatly, for example http://developer.piwik.org/guides/media-analytics/reference where we always need to explain how and where to call different kind of plugin tracker methods.

It would also make it more robust since tracker.trackFooBar() would result in an error when it is not defined but in the push method we can log or ignore certain methods, etc

It would also work with global tracker plugin methods (the ones that have ::) and works perfectly with custom tracker methods. Even when a plugin is uninstalled tracking would still work because tracker.MediaAnalytics.scanForMedia would not result in an error when done like this: tracker.push(['MediaAnalytics.scanForMedia']).

Easier to port code between _paq.push and multiple trackers. Because syntax is the same it is much easier to move from one solution to another.

@hpvd commented on December 19th 2016

+1

Powered by GitHub Issue Mirror