Server-side Google Analytics
While Google Analytics is amazing for its simple integration and powerful analytics, I’ve always been unhappy that it requires downloading a large resource and results in additional HTTP requests.
Still, analytics are valuable, open-source analytics solutions like AWStats aren’t great, Google Analytics is great, Apache access logs contain data sufficient for counting pageviews (etc) and Google Analytics provides a Measurement Protocol for “[making] HTTP requests to send raw user interaction data directly to Google Analytics servers,” and so because of all that
apache2ga was born.
apache2ga is a script that processes Apache access logs, starting from the byte last read, finds page views and sends them off to Google Analytics.
Installation simply requires specifying the hostname and tracking ID in the script, then setting up a CRON job.
The script source is on Github here.
AWStats is good enough that I tried to build around it (see “Web Analytics with AWStats in 2018“), but it fell short for several reasons including some that are not the fault of AWStats. The issues included: required merging the SSL and non-SSL logs; including non-pageviews (like images) by default; display of bots in metrics; bot filtering isn’t perfect; it only updates once a day; it requires logging in to CPanel; there’s no WordPress dashboard widget plugin; there’s no Google Search Console integration; there’s no automated email reports. Many of those could be fixed settings tweaks or plugins, but it’s more work than I’m willing to do.