Campaign Tracking via PHP Tracker API

Hello everybody,

first of all thank you very much for this great product!

Right now, I have a little problem and I hope you can help me solving it: I want to track campaigns using the PHP Tracker API and I can’t get campaigns to show up in my reports. Here is my code:

require_once './PiwikTracker.php';
  PiwikTracker::$URL = '';
  $t = new PiwikTracker( 19 );
  $cp[0] = 'min_test';
  $cp[1] = 'min_test';

    // Mandatory: set the URL being tracked
    $t->setUrl( '' );


and the api call:

Please note that tracking actually works for sitename e.g. Sitename “TEST_Z” actually shows up in report, but just campaigns doesn’t.

Since it didn’t work I also added pk_campaign and pk_kwd to the api call url:

But still no luck :frowning: I hope you can help me.

Thank you!


I was wondering if anyone can tell me if the functionality in the PHP Tracker API for tracking campaigns already exists? Can setAttributeInfo only be used for goal tracking?

Thank you.

Yes you can, you have to call setUrl() with the URL containing campaign parameters as per

Thanks a lot, Matt!

This actually worked out great! I would love to see that in the Piwik Tracker API as I couldn’t get any result using setAttributeInfo (I assume this is just used for goal tracking).

Here ist my minimal tracking example. Be sure to fill $pk_ vars on the top.

define('PIWIK_INCLUDE_PATH', dirname(__FILE__));  
require_once PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/PiwikTracker.php';
PiwikTracker::$URL = 'http://urltopiwik';
$t = new PiwikTracker($pk_siteid);

With the example above, campaigns show up in reports of the defined site ($pk_siteid).

Thank you.