如何为Google Adwords CLICK_PERFORMANCE_REPORT

时间:2016-04-07 11:43:30

标签: google-adwords awql

我正在尝试查询adwords api(v201603)并使用/扩展所提供的Java示例。

我遇到的问题是能够为CLICK_PERFORMANCE_REPORT报告指定下载报告数据的特定日期。此报告仅限于一次返回一天的数据(最多90天)。

我可以使用说明符获取今天和昨天的数据:ReportDefinitionDateRangeType.TODAY和ReportDefinitionDateRangeType.YESTERDAY,但我真正需要做的是能够指定过去90天内的特定日期以获取尽可能多的历史数据尽可能。

我尝试了以下内容:

    DateRange dr = new DateRange();
    dr.setMin("20160401");
    dr.setMax("20160402");
    selector.setDateRange(dr);

    reportDefinition.setDateRangeType(ReportDefinitionDateRangeType.CUSTOM_DATE);
    reportDefinition.setReportType(ReportDefinitionReportType.CLICK_PERFORMANCE_REPORT);
    reportDefinition.setDownloadFormat(DownloadFormat.CSV);

使用和不使用自定义日期说明符 - 并且会出现以下错误:

由于以下原因未下载报告:HTTP响应代码:400,触发:报告类型需要一天DateRange:CLICK_PERFORMANCE_REPORT,类型:ReportDefinitionError.INVALID_DATE_RANGE_FOR_REPORT

任何帮助都非常感谢,提前感谢

2 个答案:

答案 0 :(得分:2)

您将不得不使用DURING和相同的日期字符串。

... + 'DURING 20161004,20161004';

答案 1 :(得分:0)

AdWords脚本的单日迭代器CLICK_PERFORMANCE_REPORT:

var start = new Date("12/01/2016");
var end = new Date("12/18/2016");

while(start < end){

   var newDate = start.setDate(start.getDate() + 1);
   start = new Date(newDate);
   singleDay = start.toISOString().substring(0, 10).replace(/-/g,"");
   console.log(singleDay);

}

Utilities.formatDate(start, timeZone, "yyyyMMdd");将日期对象格式化为8位整数,因此:

singleDay = Utilities.formatDate(start, timeZone, "yyyyMMdd");

singleDay

中使用'DURING ' + singleDay + ',' + singleDay);

Working with Dates and Times #Reporting — AdWords Scripts

相关问题