Google 分析 API - 网站访问量最大的部分
Google Analytics API - Website most visited sections
我在 Google 分析网站中生成了一份特定报告。
http://www.google.com/analytics
此报告参考了网站访问量最大的内容,您可以通过访问以下部分来执行此操作:
报告 > 行为 > 网站内容 > 所有页面
并设置网页浏览量指标
但是我在通过 API 生成此报告时遇到了问题。如何通过调用 Google Analytics-API?
获得相同的结果
在Java中应该是这样的:
private static GaData getResults(Analytics analytics, String profileId) throws IOException {
// Query the Core Reporting API for the number of page views
// in the past seven days.
return analytics.data().ga()
.get("ga:" + profileId, "7daysAgo", "today", "ga:pageviews")
.execute();
}
但我不知道如何定义上述所需的行为,有什么想法吗?
您应该查看 dimensions and metrics and decide what combination of information you are trying to request. in your case probably the metric ga:pageviews and the dimension ga:pagePath. the Core reporting developer guides 的完整列表,其中提供了几个请求维度和指标的示例。
analytics.data().ga()
.get(tableId, // Table Id.
"2012-01-01", // Start date.
"2012-01-15", // End date.
"ga:pageviews") // Metrics.
.setDimensions("ga:pagePath")
.setMaxResults(25);
这是您尝试调用的方法的具体 Java reference doc。
我在 Google 分析网站中生成了一份特定报告。
http://www.google.com/analytics
此报告参考了网站访问量最大的内容,您可以通过访问以下部分来执行此操作:
报告 > 行为 > 网站内容 > 所有页面
并设置网页浏览量指标
但是我在通过 API 生成此报告时遇到了问题。如何通过调用 Google Analytics-API?
获得相同的结果在Java中应该是这样的:
private static GaData getResults(Analytics analytics, String profileId) throws IOException {
// Query the Core Reporting API for the number of page views
// in the past seven days.
return analytics.data().ga()
.get("ga:" + profileId, "7daysAgo", "today", "ga:pageviews")
.execute();
}
但我不知道如何定义上述所需的行为,有什么想法吗?
您应该查看 dimensions and metrics and decide what combination of information you are trying to request. in your case probably the metric ga:pageviews and the dimension ga:pagePath. the Core reporting developer guides 的完整列表,其中提供了几个请求维度和指标的示例。
analytics.data().ga()
.get(tableId, // Table Id.
"2012-01-01", // Start date.
"2012-01-15", // End date.
"ga:pageviews") // Metrics.
.setDimensions("ga:pagePath")
.setMaxResults(25);
这是您尝试调用的方法的具体 Java reference doc。