matomo-php-tracker icon indicating copy to clipboard operation
matomo-php-tracker copied to clipboard

Not possible to create multiple Piwik tracker instances having different API urls

Open tsteur opened this issue 9 years ago • 4 comments

Because $URL is a constant and not a property of the class: https://github.com/piwik/piwik-php-tracker/blob/1.0.0/PiwikTracker.php#L32

$tracker1 = new \PiwikTracker(1, 'http://demo.piwik.org/piwik.php');
$tracker2 = new \PiwikTracker(1, 'http://apache.piwik/piwik.php');

Both tracker instances will use http://apache.piwik/piwik.php as URL.

Use case see https://github.com/piwik/piwik/issues/4589 where up to 3 trackers can be configured and we need to send the same data to different trackers.

tsteur avatar Oct 07 '15 13:10 tsteur

Ran into the issue again... causing wrong tracking results... this behaviour is totally unexpected.

It would be an easy change to a local property instead of a global static property but it may cause issues re backwards compatibility.

Any thoughts @mattab ?

tsteur avatar Feb 04 '19 20:02 tsteur

BTW we ran into this issue several times now

tsteur avatar Feb 04 '19 20:02 tsteur

Think we can just add an API URL property and change self::$URL as usual. Anyone that relies on the $URL property would have the same broken behavior, but the tracker would work properly.

diosmosis avatar Feb 04 '19 21:02 diosmosis

👍

tsteur avatar Feb 04 '19 22:02 tsteur