I'm practicing to work with GAPI and so far, I got most things to work.
At the moment I'm stuck on displaying the 5 most used keywords. All my code returns is an empty array.
I've been trying to find a solution, but so far with no success.
This is my code:
<?php
$ga->requestReportData(GA_PROFILE_ID, 'searchKeyword', 'pageviews', '-pageviews', null, null, null, 1, 5);
foreach($ga->getResults() as $result) {
echo "$result - ".$result->getpageViews();
}
?>
Eventually, I found it myself.
Appearantly, searchKeyword is for internal searches, and keyword for source searches.
Source:
Keyword: https://developers.google.com/analytics/devguides/reporting/core/dimsmets/trafficsources#ga:keyword
searchKeyword: https://developers.google.com/analytics/devguides/reporting/core/dimsmets/internalsearch#ga:searchKeyword