Google Analytics is an outstanding website analytics tool that gives you way more information about your website than you probably need. Better to get more than you want than not enough, right? Anyways I check my website statistics more often than I should and it ends up taking a few minutes to get logged in, select the right site, select the current day, etc. I found a great Google Analytics PHP API that allows me to get just the statistics I’m looking for.
The PHP Library
The PHP class I found, analytics, can be downloaded at http://www.swis.nl/ga/. The site also gives a few solid examples.
//session_start for caching, if desired
//get the class
//sign in and grab profile
$analytics = new analytics('email@example.com', 'myP@ssw0rd');
//set the date range for which I want stats for (could also be $analytics->setDateRange('YYYY-MM-DD', 'YYYY-MM-DD'))
//get array of visitors by day
//get array of pageviews by day
The Sample PHP Results
The above code retrieved visits and pageviews for the current month. What’s returned is an array that looks as follows:
 => 6539
 => 6677
 => 6160
 => 5563
 => 2964
 => 2973
 => 5080
 => 6078
 => 5927
 => 6177
A very simple array numbered by day. You could do anything you wanted with the array — create averages, peaks, lows, etc.