Web Analytics with awstats in 2018
Published on .
There are a wealth of free web analytics tools (like Google Analytics,) but they add overhead to every page load, require webmasters to relinquish control, inherently employ third-party user tracking and are may be redundant to existing processes. The alternative is to just use access logs and software like awstats, which is just what I’ve opted for, but with customization (since everything is worth over engineering!) including:- Multisite Summary
- Static Generation
- Custom Theme
- Breadcrumbs
- Log merging
- Basic Auth
awstats.conf
files must be in the same directory as awstats.pl
and the working directory must be the location of the awstats.pl
script.
With that sorted out, it was a short script to generate static copies of the reports, get the paths right for the assets (icons, css, etc) and putting them somewhere web accessible. My server also stores all of the “database text files in the same directory key by their subdomain, so I settled on a config.json
file to specify which to process and how to map them to their actual domain name.
Lastly came theming and breadcrumbs. awstats allows a configurable stylesheet, making theming quite simple (especially if you just borrow from kogakure’s gitweb theme like I did.) The breadcrumbs are accomplished by using a form of str_replace('{{breadcrumbs}}',$breadcrumbs)
which is lazy but works fine.
Accessing the result requires SSL and basic auth credentials.