Google Analytics API Stacked Pageviews for PHP 4

on 10th August
  • seomoz
  • seo
  • google analytics
  • php4
  • csv
  • chart generation
This technique, originally published on SEOMoz, outlines how to generate reports and charts depicting the performance of different sections of a website over a given time frame as opposed to a flat overall view of the website's traffic. The raison d'etre is that different website sections perform differently.

When I came across this article, I was intrigued and thought it invaluable to employ it for our clients. The only downside was the manual collection of data. Thankfully, others also felt this a major drawback and Maki Car Rental produced a couple of PHP files to automate the data collection process.

This worked superbly on some of our clients servers however some were still running PHP 4 so we've made available a version of the code which uses PHP 4 functions rather than the original PHP 5 implementation. We've also tacked on a small UI so customised reports/metrics/date ranges can be produced quickly. The PHP 4 version is available for download here.

This version of the script also allows you to quickly adjust the CSV delimiter by altering the $csv_field_delim variable. Many thanks to those involved, this is an absolutely superb technique for collecting data enabling users of Google Analytics to make valuable business decisions.

As with all articles on Celtic Productions, this article is protected by international copyright laws. It may be linked to (we are of course most grateful of links to our articles), however, it may never be reproduced without the prior express permission of its owners, Celtic Productions.