1
votes

I just want to get the basic graph that is shown on the Google Analytics frontpage. Number of views over the course of a month. This: http://i.imgur.com/0Jdpm.png

require_once('lib/gapi.class.php');
$ga = new gapi('asdf','qwerty');

$dimensions     = array('pagePath'); 
$metrics        = array('visits');
$sortMetric     = null;
$filter     = null;
$startDate      = '2012-10-05';
$endDate        = '2012-11-04';
$startIndex     = 1;
$maxResults     = 10;

$ga->requestReportData('48607689', $dimensions, $metrics, $sortMetric, $filter, $startDate, $endDate, $startIndex, $maxResults);

print_r($ga->getResults());

But this seems to return views per page and not the whole website. What metrics/dimensions do I have to use?

1

1 Answers

1
votes

Use date as the dimension. Visits is correct for metric (assuming you want "Visits" and not "Views" as you state in your question). And set $maxresults to at least the number of days in your range (i.e. some number greater than 31).

You should check out the GA Query Explorer; great tool for getting familiar with the metrics and dimensions.