I am trying to retrieve ga:pagePathLevel1
here but getting error
Warning: array_merge(): Argument #2 is not an array in ...\google-api-php-client\src\Google\Service\Analytics.php on line 1925
function getResults(&$analytics, $profileId) {
// Calls the Core Reporting API and queries for the number of sessions
// for the last seven days.
$analytica_report['data_ga_get'] = $analytics->data_ga->get(
'ga:' . $profileId,
'7daysAgo',
'today',
'ga:sessions,ga:pageviews,ga:uniquePageviews,ga:bounces,ga:timeOnPage,ga:sessionDuration,ga:entrances,ga:exits,ga:searchUniques,ga:transactions',
'ga:pagePathLevel1,ga:pagePathLevel2'
);
Can anybody suggest how I can make it correct ?
The last parameter in the method is optional parameters. Try something like this
$optParams = array(
'dimensions' => 'ga:pagePathLevel1,ga:pagePathLevel2');
return $service->data_ga->get(
'ga:' . $profileId,
'7daysAgo',
'today',
'ga:sessions,ga:pageviews,ga:uniquePageviews,ga:bounces,ga:timeOnPage,ga:sessionDuration,ga:entrances,ga:exits,ga:searchUniques,ga:transactions',
$optParams);
}
You might also find the documentation useful.