无法检索pagePathLevel1维度

时间:2015-11-05 07:32:39

标签: php google-analytics-api google-api-php-client

我正在尝试在此处检索ga:pagePathLevel1但收到错误

  

警告:array_merge():参数#2不是数组   ... \ google-api-php-client \ src \ Google \ Service \ Analytics.php就行了   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'      
      );

有人可以建议我如何使其正确吗?

1 个答案:

答案 0 :(得分:0)

方法中的最后一个参数是可选参数。试试这样的事情

$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);
}

您可能还会发现documentation有用。