I’m trying to work with Google Analytics Core API.
I am using their sample page, and if I just do this, it works:
return $analytics->data_ga->get(
'ga:' . $profileId,
'2008-01-01',
'today',
'ga:pageviews');
This, when applied to another function, gets all the pageviews for my entire site/property all-time.
But, I want pageviews for a specific pagePath, so I attempt to just add the dimension ga:pagePath, and the API stops functioning or times out. I try to add the full set of parameters…
function getResults($analytics, $profileId) {
$optParams = array(
'dimensions' => 'ga:pagePath',
'filters' => 'ga:pagePath==/live-by-night/trailer',
'max-results' => '1');
return $analytics->data_ga->get(
'ga:' . $profileId,
'2008-01-01',
'today',
'ga:pageviews',
$optParams);
}
This breaks the response, and instead I get:
Uncaught exception ‘Google_Service_Exception’ with message
‘{“error”:{“errors”:[{“domain”:“global”,“reason”:“backendError”,“message”:“There
was a temporary error. Please try again
later.”}],“code”:503,“message”:“There was a temporary error. Please try
again later.”}}’
Not sure if it’s temporary, as I get temporary banned for the bad request happening too often.
Can’t figure out what I’m doing wrong.
All feedback appreciated.
Cheers!
Ryan