我尝试为单个指标获取多个维度值。我收到错误
" {"错误":{"代码":400,"消息":"未知维度:ga: sourceMedium,ga:deviceCategory","错误":[{" message":" Unknown dimension(s):ga:sourceMedium,ga:deviceCategory", "域":"全球","原因":" badRequest" }]," status":" INVALID_ARGUMENT" "。
如果我发送单个维度值,那么工作正常 " $浏览器的>的setName(" GA:sourceMedium&#34); "
<ul style="list-style-type:none; padding-left: 0">
<li>
<a href="https://www.google.com">
<div style="background-image:url(http://placehold.it/350x150); height: 150px; width: 350px;"/>
</a>
</li>
</ul>
答案 0 :(得分:1)
您应为每个维度获取Google_Service_AnalyticsReporting_Dimension()
的新实例,例如:
$sourceMedium = new Google_Service_AnalyticsReporting_Dimension();
$sourceMedium->setName("ga:sourceMedium");
$deviceCategory = new Google_Service_AnalyticsReporting_Dimension();
$deviceCategory->setName("ga:deviceCategory");
然后当你setDimensions()
时,你应该这样做:
$request->setDimensions(array($sourceMedium, $deviceCategory));
易?
答案 1 :(得分:0)
以下是样本 这是添加多个维度和指标的方法..
ReportRequest request = new ReportRequest()。setViewId(VIEW_ID).setDateRanges(Arrays.asList(dateRange))。setDimensions(Arrays.asList(browser,browserVersion))。setMetrics(Arrays.asList(sessions));