获取分析视图(配置文件)的目标列表
Get the list of goals for a Analytics View (profile)
使用 Google Analytics Core Reporting API 来查询目标转化数据,如果我使用以下参数查询 API,我可以获得总目标转化:
$metrics = 'ga:goal1Completions,ga:goal2Completions,ga:goal3Completions',
[
'dimensions' => 'ga:date',
'output' => 'dataTable'
]
问题是我不知道每个View(Profile)注册了多少个目标,在这个例子中,目标3不存在。
如何列出特定视图(配置文件)的可用目标?
您可以从 Google 分析管理 API 调用 goals.list
method。
/**
* Example #1:
* Requests goals for a single view (profile).
*/
try {
$goals = $analytics->management_goals->listManagementGoals($ACCOUNT_ID,
$PROPERTY_ID,
$VIEW_ID);
} catch (apiServiceException $e) {
print 'There was an Analytics API service error '
. $e->getCode() . ':' . $e->getMessage();
} catch (apiException $e) {
print 'There was a general API error '
. $e->getCode() . ':' . $e->getMessage();
}
目标也是 templatized deimension/metric, which should let you know at least the minimum and maximum values if you are to query the Google Analytics Metadata API。
使用 Google Analytics Core Reporting API 来查询目标转化数据,如果我使用以下参数查询 API,我可以获得总目标转化:
$metrics = 'ga:goal1Completions,ga:goal2Completions,ga:goal3Completions',
[
'dimensions' => 'ga:date',
'output' => 'dataTable'
]
问题是我不知道每个View(Profile)注册了多少个目标,在这个例子中,目标3不存在。
如何列出特定视图(配置文件)的可用目标?
您可以从 Google 分析管理 API 调用 goals.list
method。
/**
* Example #1:
* Requests goals for a single view (profile).
*/
try {
$goals = $analytics->management_goals->listManagementGoals($ACCOUNT_ID,
$PROPERTY_ID,
$VIEW_ID);
} catch (apiServiceException $e) {
print 'There was an Analytics API service error '
. $e->getCode() . ':' . $e->getMessage();
} catch (apiException $e) {
print 'There was a general API error '
. $e->getCode() . ':' . $e->getMessage();
}
目标也是 templatized deimension/metric, which should let you know at least the minimum and maximum values if you are to query the Google Analytics Metadata API。