Learning to Love the API: Analytics

Thursday, October 7th, 2010

Media is cool and all, but don’t forget about the raw data. With Google Analytics’ Data API you can parse and display that juicy data. For the PHP people, I would highly recommend using GAPI (Google Analytics API PHP Interface) to simplify things!

The following is used to display the most read pages on our news site.

requestReportData(ga_profile_id,array('pageTitle','pagePath'),array('pageviews'),array('-pageviews'),'pagePath!=/','2009-10-01' ,null,1,10 );
	echo "
    "; foreach($ga->getResults() as $result){ $title = preg_replace( '/( \| PCC News)|(Feature: )/','',$result->getPageTitle() ); echo '
  • '.$title.' ('.$result->getPageviews().' views)
  • '; } echo "
"; ?>

One Response to “Learning to Love the API: Analytics”

  1. gabriel nagmay (dot com) | Archive » Learning to Love the API Says:

    […] Analytics (Google Analytics) […]

Leave a Reply

You know you want to...