Question

I have a PHP website with piwik as analytics. Certain pages are requested by different API's which don't execute HTML/JS so I need to call piwik from within the php files. Using the piwik tracking api seems wrong as it sends out HTTP requests and demands I manually set the IP address among other nuances. Piwiki is installed on the same server so I guess the solution is something related to:

require_once "../piwik/piwik.php"

maybe....

How do I do this?

Was it helpful?

Solution

If you make the requests to the local server (without external DNS) then it should be fast enough and not add much overhead. Using the tracking API is the way to go in terms of ease of use and maintainability. You can also probably require "piwik.php" assuming you have set all the $_GET parameters correctly for Piwik to track the requests.

Some of the tracking parameters are documented in: https://matomo.org/docs/tracking-api/#toc-tracking-api-rest-documentation

OTHER TIPS

The Piwik website has a full example implementation of the PHP API. Setting an IP is only required if you want to force requests to appear to come from a particular client.

Including the Piwik PHP files directly will not work unless you have heavily adapted your code around them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top