[英]Google Analytics Report API v4: get Sessions and Revenue data
I trying to get Sessions, Revenue, Transactions, Bounce Rate data from Google Analytics Report API v4 with grouping by Chanel: 我试图通过Chanel分组从Google Analytics Report API v4获取会话,收入,交易,跳出率数据:
Right now I'm programming a Java module with test Request which has setted following parameters: 现在,我正在使用测试请求编程Java模块,该模块设置了以下参数:
Dimensions: 尺寸图
ga:acquisitionTrafficChannel; ga:acquisitionTrafficChannel;
Metrics: 指标:
ga:sessions ga:sessions
ga:percentNewSessions ga:percentNewSessions
ga:newUsers ga:newUsers
When I use ga:acquisitionTrafficChannel + ga:sessions
GA Report api returns values, but when I try to add in request ga:percentNewSessions, ga:newUsers , it returns error: 当我使用
ga:acquisitionTrafficChannel + ga:sessions
GA报告api返回值时,但是当我尝试添加请求ga:percentNewSessions,ga:newUsers时 ,它返回错误:
{
"domain": "global",
"message": "Selected dimensions and metrics cannot be queried together.",
"reason": "badRequest"
}
To perform request in code I do following: 要执行代码中的请求,请执行以下操作:
DateRange dateRange = new DateRange();
dateRange.setStartDate("2015-06-15");
dateRange.setEndDate("2015-06-30");
ReportRequest request = new ReportRequest()
.setViewId(context.getProperty(VIEW_ID).evaluateAttributeExpressions().getValue())
.setDateRanges(Arrays.asList(dateRange))
.setDimensions(Arrays.asList(
new Dimension().setName("ga:acquisitionTrafficChannel")
))
.setMetrics(Arrays.asList(
new Metric().setExpression("ga:sessions"),
new Metric().setExpression("ga:percentNewSessions"),
new Metric().setExpression("ga:newUsers")
));
ArrayList<ReportRequest> requests = new ArrayList<>();
requests.add(request);
GetReportsRequest getReport = new GetReportsRequest().setReportRequests(requests);
GetReportsResponse response = service.reports().batchGet(getReport).execute();
How to do request correctly? 如何正确提出要求? Is in the right direction do I go?
我走的方向正确吗?
Because as I said, I will need to do same thing with Revenue, Bounce Rate.. but I not fully understand how to combine Metrics and Dimensions without errors. 因为正如我所说,我将需要对收入,跳出率做同样的事情。但是我没有完全理解如何正确地结合指标和维度。
Thanks for any help 谢谢你的帮助
About my question: 关于我的问题:
As solution for my needs I used following combination in code: 为了满足我的需求,我在代码中使用了以下组合:
To get all Channel groups ("Organic Search, Email, Direct, etc") I used following dimension: ga:channelGrouping
- it will return all 为了获得所有频道组(“有机搜索,电子邮件,直接搜索等”),我使用了以下尺寸:
ga:channelGrouping
它会返回所有
To get values for Sessions, Revenue, Transactions, Bounce Rate, etc I used following metrics: 为了获取会话,收入,交易,跳出率等的值,我使用了以下指标:
ga:sessions
ga:transactionRevenue
ga:transactions
ga:bounceRate
Also here can be more metrics if it is needed. 如果需要,这里也可以有更多指标。
Maybe it will be useful to somebody. 也许对某人有用。
Actually, question about error with combination in question (with ga:acquisitionTrafficChannel
) is still open :) 实际上,有关组合错误(带有
ga:acquisitionTrafficChannel
)的问题仍未解决:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.