我正在尝试使用Google Adsense Management API收集数据并输出到Google电子表格。
但是,虽然我只想输出“收入”(指标中的“收益”),但结果也会输出开始日期。
var ss = SpreadsheetApp.getActiveSpreadsheet(); //get current active spreadsheet
var sheet = ss.getSheetByName('name'); //sheet name
var adClientId = 'ca-pub-0000000000000000' //adsense ID
var startDate = 'startOfMonth-1m'; //from start of last month
var endDate = 'startOfMonth-1d'; //to end of last month
var metrics = ['EARNINGS'] //state which data to get
var domain = 'mywebsite.com'; //filter domain name
var args = {
'metric': metrics,
'dimension': ['MONTH'],
'filter': ['AD_CLIENT_ID==' + adClientId, 'DOMAIN_NAME==' + domain],
};
function report() {
var report = AdSense.Reports.generate(startDate, endDate, args).getRows();
sheet.getRange(16, 3, report.length,
metrics.length+1).setValues(report);
}