Google 分析、维度和指标 - 怎么做?
Google Analytics, Dimensions & Metrics - How to?
我终于弄清楚了我是如何连接到 Google 分析的,正确的 - 我现在能够访问某些点的数据。我正在使用 google-api-php-客户端。
我可以很好地处理指标,方法是
return $analytics->data_ga->get(
'ga:' . $profileId,
'7daysAgo',
'today',
'ga:sessions,ga:pageviews,ga:sessionDuration');
这将 return 我的会话数、综合浏览量和会话持续时间。但现在假设我也对使用某些维度感兴趣 - 也许我想要查询 return 搜索引擎所有流量的网站使用数据,按综合浏览量降序排序。
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()
我尝试在数组中提供维度和过滤器,但 return 给我以下错误
Warning: Illegal string offset 'type' in
xxxxxxxxx/src/Google/Service/Resource.php on line 269
Warning: Illegal string offset 'location' in
xxxxxxxxx/src/Google/Service/Resource.php on line 272
Warning: Illegal string offset 'location' in
xxxxxxxxx/src/Google/Service/Resource.php on line 274
尺寸不是必需的,因为它们是选项参数的一部分。
//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 数组
我终于弄清楚了我是如何连接到 Google 分析的,正确的 - 我现在能够访问某些点的数据。我正在使用 google-api-php-客户端。
我可以很好地处理指标,方法是
return $analytics->data_ga->get(
'ga:' . $profileId,
'7daysAgo',
'today',
'ga:sessions,ga:pageviews,ga:sessionDuration');
这将 return 我的会话数、综合浏览量和会话持续时间。但现在假设我也对使用某些维度感兴趣 - 也许我想要查询 return 搜索引擎所有流量的网站使用数据,按综合浏览量降序排序。
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()
我尝试在数组中提供维度和过滤器,但 return 给我以下错误
Warning: Illegal string offset 'type' in xxxxxxxxx/src/Google/Service/Resource.php on line 269
Warning: Illegal string offset 'location' in xxxxxxxxx/src/Google/Service/Resource.php on line 272
Warning: Illegal string offset 'location' in xxxxxxxxx/src/Google/Service/Resource.php on line 274
尺寸不是必需的,因为它们是选项参数的一部分。
//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 数组