piwik: import apache access.log

Piwik can be made to function as a logfile analyzer. Sure, we will not get live statistics, no installed browser-plugins, no screen resolutions of our visitors. But i really don’t need that. Also my visitors privacy is respected as tracking cookies are not created/referenced.

I just care for total numbers and referers of particular sites. A nice user interface is a plus.

First we have to change directory into piwiks log-analytics directory:

cd /path/to/piwik/misc/log-analytics

Next we want to process all apache access.log files found in a given directory:

find /path/to/some/logfiles/access*.log* -maxdepth 1 -type f | while read file; do \
    python import_logs.py \
        --idsite=1 \
        --url=http://url.to.piwik.com/piwik \
        --recorders=2 \
        --enable-bots \
        --enable-static \
        --enable-http-errors \
        --enable-http-redirects \
        --enable-reverse-dns \
    $file; \

Make sure those apache logfiles did not get imported into piwik again, as it may falsify the results and will lead to duplicate entries.