Ironvine Analytics Web Analytics, Data Analysis, Online Marketing, and Search Engine Information.

30Apr/09Off

PHP Export to Excel

Here is some code I found that will allow you from PHP code to export data directly into an excel file. I haven't personally tested this but the source I had for it was no longer available online so I'm reposting it here.

< ?php session_start();
$ID=$_SESSION["ReportData"];
?>
< ?php
$line = '';
foreach($ID as $line) {
foreach($line as $key => $value) {
$data .= $value . "\t";
}
$data .= "\n";
}

$data = str_replace("\r","",$data);
?>
< ?php
if ($data == "") {
$data = "\n(0) Records Found!\n";
}
?>
< ?php
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=extraction.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo "$data";
?>

Tagged as: , , , Comments Off
28Apr/09Off

PHP Output Buffer

While working with the new Google Analytics Export API and a PHP example, I wanted to be able to output a csv version of the data to a file that could be downloaded.

I found this PHP function that allows output buffering. Still working the bugs out of my data export, but the output code works well.

http://my.opera.com/zomg/blog/2007/10/03/how-to-easily-redirect-php-output-to-a-file

Tagged as: , , Comments Off
22Apr/09Off

Google Analytics API

Google has opened up the Google Analytics API (export) for general use!

http://code.google.com/apis/analytics/docs/gdata/1.0/gdataProtocol.html

Alex C wrote a quick PHP script to pull pageviews from all available accounts. Read the setup here: http://www.alexc.me/using-the-google-analytics-api-getting-total-number-of-page-views/74/

16Apr/09Off

Google Analytics Profile Limits

There are a maximum of 50 profiles per Google Analytics Account, and a limit of 25 Analytics Accounts per email address.