PHP client directly importing log files (not via http)

Has anyone had any success creating a php script that imports log files directly into Matomo without going through a web interface.

It seems daft to have nginx create log files, send them to syslog, syslog call a php script, and for that php script to then have to access a webserver to import the log files. (Although if matomo is on a different server this is necessary).

I’ve tried and failed miserably and just wondering if someone has done this before so I can get some pointers.



I am not sure what you mean? Are you trying to use your serverlog to track visits?

This is already possible with Log Analytics:
Log Analytics - Analytics Platform - Matomo
How to use Log Analytics tool - Analytics Platform - Matomo

Or are you trying to do something else?

Hi yes that’s it, server log into Matomo. But to me it seems silly, if everything is on the same machine, to use a network interface to do so.

Why use a separate python script (which in essence is what the supplied script is) to create a http call to matomo when you could use a php file which understands the existing matomo php code/config and execute that locally.

As at the moment this is how log analytics works (I think):
webserver create log line in file
-> scheduled job reads log file & passes log / logline to python script
-> python script calls webserver
-> webserver calls matomo application (maybe directly if apache/or through fcgi server)
-> matomo is updated

or you could have
webserver sends log line to rsyslog
-> rsyslog executes local matomo php
-> matomo is updated


The main reason is to make it more reliable. As it is using the same API as the JS tracker and all tracking SDKs there are less things that could break.