Php 谷歌分析、维度和;指标-如何?

Php 谷歌分析、维度和;指标-如何?,php,google-analytics-api,google-api-php-client,Php,Google Analytics Api,Google Api Php Client,我终于明白了我是如何连接到Google Analytics的,对吗?现在我可以访问某个点的数据了。我正在使用google api php客户端 通过这样做,我可以很好地处理指标 return $analytics->data_ga->get( 'ga:' . $profileId, '7daysAgo', 'today', 'ga:sessions,ga:pageviews,ga:sessionDuration'); 它将返回会话数、页面浏

我终于明白了我是如何连接到Google Analytics的,对吗?现在我可以访问某个点的数据了。我正在使用google api php客户端

通过这样做,我可以很好地处理指标

     return $analytics->data_ga->get(
    'ga:' . $profileId,
    '7daysAgo',
    'today',
    'ga:sessions,ga:pageviews,ga:sessionDuration');
它将返回会话数、页面浏览量和会话持续时间。但是现在让我们假设我也对使用一些维度感兴趣-也许我希望查询返回搜索引擎所有流量的站点使用情况数据,按页面浏览量降序排序

   dimensions=ga:source
   metrics=ga:pageviews,ga:sessionDuration,ga:exits         
   filters=ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==organic,ga:medium==ppc
   sort=-ga:pageviews
data_ga->get函数调用以下参数:$ids、$startDate、$endDate、$metrics、$optParams=array()

我尝试在数组中提供维度和过滤器,但它返回以下错误

警告:中的字符串偏移量“type”非法 第269行的xxxxxxxxx/src/Google/Service/Resource.php

警告:中的字符串偏移量“位置”非法 第272行的xxxxxxxxx/src/Google/Service/Resource.php

警告:中的字符串偏移量“位置”非法 第274行的xxxxxxxxx/src/Google/Service/Resource.php


尺寸不是必需的,因此它们是选项参数的一部分

//Adding Dimensions
$params = array('dimensions' => 'ga:userType'); 
// requesting the data  
$data = $service->data_ga->get("ga:89798036", "2014-12-14", "2014-12-  14", "ga:users,ga:sessions", $params );  
过滤器和排序也可以添加到$parms数组中