Hi,
I'm attempting to pull campaign data including the asset automation setting field from the campaign report. When I add the 'campaign.asset_automation_settings field', I get the error:
QueryError.UNRECOGNIZED_FIELD: Unrecognized field in the query: 'campaign.asset_automation_settings'
Not sure why, when the field is included in the attributed resource fields just like the other fields I'm pulling:
campaign.id and
campaign.name.
I've added the script below (I've remove the sheet url & CIDs), along with some screenshots of the error and the field within the Google Ads API.
Any help would be much appreciated. Thank you.
Script:
function main(){ const ss = SpreadsheetApp.openByUrl("sheet_url"); const SHEET_NAME = 'raw'; const sheet = ss.getSheetByName(SHEET_NAME); sheet.getRange('A:E').clearContent(); const headerRow = ["CID", "Account Name", "Campaign Id", "Campaign", "Automation Setting"]; sheet.getRange("A1:E1").setValues([headerRow]).setFontWeight("bold"); const accountIterator = AdsManagerApp.accounts().withIds(['cids']).get(); while (accountIterator.hasNext()) { const account = accountIterator.next(); Logger.log(account.getName() + ' complete'); AdsManagerApp.select(account); const custId = AdsApp.currentAccount().getCustomerId(); const custName = AdsApp.currentAccount().getName(); const report = AdsApp.search( `SELECT campaign.id, campaign.name, campaign.asset_automation_settings FROM campaign WHERE segments.date DURING THIS_MONTH AND campaign.advertising_channel_type = 'PERFORMANCE_MAX' AND campaign.status = 'ENABLED' ` ),data = []; for(;report.hasNext();) {let query = report.next(), {id:campaignId, name:campaignName, assetAutomationSettings:settings}=query.campaign; data.push([custId, custName, campaignId, campaignName, settings])} if (data.length > 0) { sheet.getRange(sheet.getLastRow() + 1, 1, data.length, data[0].length).setValues(data); } }}