问题
I am using the adwords api to generate reports. Please bear with me as I am not too familiar with the same. I am using version v201409 of the api. I get the report columns for KEYWORD_PERFORMANCE_REPORT using getReportFields. I then try to download the report using a subset of those columns.
For KEYWORD_PERFORMANCE_REPORT I get the error:
Cannot select a combination of Device and AssistClicks,AssistClicksOverLastClicks,AssistImpressions,AssistImpressionsOverLastClicks,AveragePageviews,AverageTimeOnSite,BounceRate,Bounces,ClickAssistedConversionValue,ClickAssistedConversionValueLong,ClickAssistedConversionValueNonMoney,ClickAssistedConversions,ClickAssistedConversionsOverLastClickConversions,ImpressionAssistedConversionValue,ImpressionAssistedConversionValueLong,ImpressionAssistedConversionValueNonMoney,ImpressionAssistedConversions,ImpressionAssistedConversionsOverLastClickConversions,LastClickConversions,LastClicks,NewVisitors,Pageviews,PercentNewVisitors,VisitDuration,Visits, Type: ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT.
The question is: How do I find out a valid set of combinations of columns without going through a trial and error process.. Is there any documentation which will help me with the same.
I looked at the columns for KEYWORD_PERFORMANCE_REPORT in http://developers.guge.io/adwords/api/docs/appendix/reports and exclude the colums which the api said were "not compatible". Got a similar error. Thanks
N.B> If I try this code with the columns provided in the online example it works and downloads the report as expected. The code is: ` String[] columnNames = { "ConversionRateManyPerClickSignificance", "ConversionRateSignificance", "ViewThroughConversionsSignificance", "AccountCurrencyCode", "AccountDescriptiveName", "AccountTimeZoneId", "AdGroupId", "AdGroupName", "AdGroupStatus", "AssistImpressions", "AssistImpressionsOverLastClicks", "AverageCpc", "AverageCpm", "AveragePageviews", "AveragePosition", "AverageTimeOnSite", "BiddingStrategyId", "BiddingStrategyName", "BiddingStrategyType", "CampaignId", "CampaignName", "CampaignStatus", "ClickAssistedConversionsOverLastClickConversions", "ClickAssistedConversionValue", "Clicks", "ClickSignificance", "ClickType", "ConversionManyPerClickSignificance", "ConversionRate", "ConversionRateManyPerClick", "Conversions", "ConversionSignificance", "ConversionsManyPerClick", "ConversionTypeName", "ConversionValue", "Cost", "CostPerConversion", "CostPerConversionManyPerClick", "CostPerConversionManyPerClickSignificance", "CostPerConversionSignificance", "CostSignificance", "CpcBid", "CpcBidSource", "CpmBid", "CpmSignificance", "CriteriaDestinationUrl", "Ctr", "CtrSignificance", "CustomerDescriptiveName", "CvrSignificance", "Date", "DayOfWeek", "Device", "ExternalCustomerId", "FinalAppUrls", "FinalMobileUrls", "FinalUrls", "FirstPageCpc", "Id", "ImpressionAssistedConversions", "ImpressionAssistedConversionsOverLastClickConversions", "ImpressionAssistedConversionValue", "Impressions", "ImpressionSignificance", "IsNegative", "KeywordMatchType", "LabelIds", "Labels", "Month", "MonthOfYear", "PlacementUrl", "PositionSignificance", "PrimaryCompanyName", "QualityScore", "Quarter", "SearchExactMatchImpressionShare", "SearchImpressionShare", "SearchRankLostImpressionShare", "Slot", "TrackingUrlTemplate", "UrlCustomParameters", "ValuePerConversion", "ValuePerConversionManyPerClick", "ViewThroughConversions", "Week", "Year"
};
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();
}
}
}
`
None of the columns you mentioned in the comment below are used.
回答1:
Check the following documentation. https://developers.google.com/adwords/api/docs/appendix/reports/keywords-performance-report#activeviewcpm
For some fields "Not compatible with the following fields" option is provided. Click on that option to check the combinations that are not compatible
回答2:
The following columns are not selectable in the Keywords Performance Report in v201409:
AssistClicksOverLastClicks
Bounces
ClickAssistedConversionValueLong
ClickAssistedConversionValueNonMoney
ImpressionAssistedConversionValueLong
ImpressionAssistedConversionValueNonMoney
LastClickConversions
LastClicks
NewVisitors
Pageviews
VisitDuration
Visits
Suggest you try removing them and trying again. Failing that, post some code so we can see how you are making the call.
For future reference the AdWords Ad Hoc Reporting docs provide a downloadable CSV file for each of the report types listing the allowed metrics, attributes and segments.
回答3:
I got an same issue with you. And from my understandings, there's no API to identify which column combinations are valid in adwords so far. So I check whether the combination is valid or not before download the file by requesting real AWQL.
If the dummy AWQL returns error such as 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'
, then I modify the combination of columns by using the error details through trial and error.
I don't know if this is the best way...
来源:https://stackoverflow.com/questions/28726491/how-do-i-find-out-which-column-combinations-are-valid-in-adwords