PHP-only Piwik API?


#1

Is it possible to use the Piwik API via PHP only (no external requests like PiwikTracker.php).

I’m using PiwikTracker.php to track visitors like in this tutorial:

Unforunately, this makes every pageview add an aditional HTTP request to Piwik, which is housed on the same server.
As a result of this, my Apache workers clog up (see attached image).

Can we access the Piwik API through PHP only? So no extra requests are passed to Apache.

Thanks.


(Matthieu Aubry) #2

Hello! yes it is possible, but we haven’t documented this way. The PHP tracking API documented at: http://piwik.org/docs/tracking-api/reference/

can be used via PHP process intead of http request (eg. calling PHP executable on piwik.php)


#3

Hi Matt!

Do you mean I could do this:


$t = new PiwikTracker($idSite,'/var/www/piwik/piwik.php');
...

?

If not, could you provide an example of how to connect using PHP file?


(Matthieu Aubry) #4

eg. something like this should work:


shell_exec('/bin/php path/to/piwik.php -- "trackingQueryString=Here"')