我正在使用adwords api生成报告。请耐心听我说,我不太熟悉。我使用的是该api的v2201409版本。我使用getReportFields获取KEYWORD_PERFORMANCE_report的报告列。然后,我尝试使用这些列的子集下载报告。
对于KEYWORD_PERFORMANCE_REPORT,我得到错误:
无法选择设备和AssistClicks,AssistClicksOverLastClicks,Assistant Impression,AssistImpression OverLastClick,AveragePageviews,AverageTimeOnSite,BounceRate,Bounce,ClickAssistedConversionValue,ClickAssisted ConversionValueLong,ClickAssistedConversionValueNonMoney,ClickAssistdConversions,ClickAssisttedConversions OverLastClickConversions,Impression AssistedConversionValueNonMoney,Impression Assisted Conversions,Impression Assistant Conversions OverLastClickConversions,类型:ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT.
问题是:如何在不经过试错过程的情况下找到一组有效的列组合。。有什么文件可以帮我做同样的事情吗。
我查看了中KEYWORD_PERFORMANCE_REPORT的列http://developers.guge.io/adwords/api/docs/appendix/reports并排除api所说的"不兼容"的柱。得到了一个类似的错误。感谢
N.B>如果我用在线示例中提供的列尝试这个代码,它会正常工作,并按预期下载报告。代码为:`String[]columnNames={"ConversionRateAnyPerClickSignificance","ConversionRateSignificance","ViewThroughConversations重要性","AccountCurrencyCode","AccountDescriptiveName","AccountTimeZoneId","AdGroupId","AdGroupName","AdGroupStatus","AssistImpression","AssistImpressionOverLastClicks","平均Cpc","平均Cpm","平均页面浏览量","平均位置","AverageTimeOnSite","BiddingStrategyId","BiddingStrategyName","投标策略类型","CampaignId","CampaignName","CampaignStatus","ClickAssistedConversationsOverLastClickConversations","单击AssistedConversionValue","点击","点击意义","单击类型","ConversionManyPerClickSignificance","转换率","ConversionRateAnyPerClick","转换","转换意义","ConversationsManyPerClick","ConversionTypeName","ConversionValue","成本","CostPerConversion","CostPerConversionManyPerClick","每次转换的成本每次点击的重要性","成本转化意义","成本意义","CpcBid","CpcBidSource","CpmBid","CpmSignificance","CriteriaDestinationUrl","Ctr","CtrSignificance","CustomerDescriptiveName","Cvr重要性","日期","DayOfWeek","设备","ExternalCustomerId","FinalAppUrls","FinalMobileUrls","FinalUrls","FirstPageCpc","Id","ImpressionAssistedConversions","Impression AssistedConversationsOverLastClickConversations","ImpressionAssistedConversionValue","印象","印象意义","IsNegative","KeywordMatchType","LabelIds","标签","月份","MonthOfYear","PlacementUrl","位置重要性","PrimaryCompanyName","QualityCore","季度","SearchExactMatchImpression Share","SearchImpression Share","SearchRankLostImpressionShare","插槽","TrackingUrlTemplate","UrlCustomParameters","ValuePerConversion","ValuePerConversionManyPerClick","ViewThroughConversions","周","年度">
};
public static void downloadConsolidatedReportFile(String[] columnNames, final ReportDefinitionDateRangeType forDateRange, final ReportDefinitionReportType reportDefinitionReportType, final String to) throws Exception {
com.google.api.ads.adwords.lib.jaxb.v201409.Selector selector = new com.google.api.ads.adwords.lib.jaxb.v201409.Selector();
selector.getFields().addAll(Lists.newArrayList(columnNames));
ReportDefinition reportDefinition = new ReportDefinition();
reportDefinition.setReportName("Report " + reportDefinitionReportType.value() + " for dateRange " + forDateRange.value());
reportDefinition.setDateRangeType(forDateRange);
reportDefinition.setReportType(reportDefinitionReportType);
reportDefinition.setDownloadFormat(DownloadFormat.CSV);
ReportingConfiguration reportingConfiguration = new ReportingConfiguration.Builder()
.skipReportHeader(true)
.skipReportSummary(true)
.build();
session.setReportingConfiguration(reportingConfiguration);
reportDefinition.setSelector(selector);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(to)));
String mccId = session.getClientCustomerId(); //The id from ads.properties file
Collection<Client> clientIds = getClientAccountIds(mccId);
try {
for (Client cl : clientIds) {
BufferedReader reader = null;
String customerId = cl.id;
String name = cl.name;
session.setClientCustomerId(cl.id);
try {
ReportDownloadResponse response =
new ReportDownloader(session).downloadReport(reportDefinition);
if (response == null || response.getHttpStatus() != 200) {
handleError(response);
}
BufferedInputStream bs = new BufferedInputStream(response.getInputStream());
reader = new BufferedReader(new InputStreamReader(bs));
String line = null;
log.info("getting " + reportDefinition.getReportType().value() + " for " + customerId+" "+name);
reader.readLine(); //Skip the first line of column names
while ((line = reader.readLine()) != null) {
bw.write(line + "n");
}
} catch (DetailedReportDownloadResponseException e) {
log.error("An error was thrown downloading report for Customer id: " + customerId+" "+name, e);
//We have to do this as we have to filter out the mcc id. An exception is thrown by MCC id
if (e.getType().equals("ReportDefinitionError." + ReportDefinitionErrorReason.CUSTOMER_SERVING_TYPE_REPORT_MISMATCH.getValue())) {
continue;
} else {
throw e;
}
} catch (Exception e) {
log.error("An error was thrown downloading report for Customer id: " + customerId+" "+name, e);
throw e;
} finally {
if (reader != null) {
reader.close();
}
}
}
} finally {
if (bw != null) {
bw.flush();
bw.close();
}
}
}
`
您在下面的评论中提到的所有列都没有被使用。
检查以下文档。https://developers.google.com/adwords/api/docs/appendix/reports/keywords-performance-report#activeviewcpm
对于某些字段,提供了"与以下字段不兼容"选项。点击该选项检查不兼容的组合
v201409中的关键字性能报告中以下列不可选择:
AssistClicksOverLastClicks
Bounces
ClickAssistedConversionValueLong
ClickAssistedConversionValueNonMoney
ImpressionAssistedConversionValueLong
ImpressionAssistedConversionValueNonMoney
LastClickConversions
LastClicks
NewVisitors
Pageviews
VisitDuration
Visits
建议您尝试删除它们,然后重试。如果做不到,请发布一些代码,这样我们就可以看到您是如何打电话的。
为了将来参考,AdWords特设报告文档为每种报告类型提供了一个可下载的CSV文件,列出了允许的指标、属性和分段。
我也遇到了同样的问题。根据我的理解,到目前为止,还没有API来识别广告词中哪些列组合是有效的。因此,在下载文件之前,我通过请求真正的AWQL来检查组合是否有效。
如果伪AWQL返回错误,例如Adwords: Reporting Error: HTTP code: 400, error type: 'ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT', trigger: 'Cannot select a combination of ActiveViewCpm and ConversionCategoryName,ConversionTrackerId,ConversionTypeName', field path: 'ActiveViewCpm'
,那么我通过反复尝试使用错误详细信息来修改列的组合。
我不知道这是不是最好的方式。。。