Campaign Asset Automation Setting Issue

61 views
Skip to first unread message

Q Florence

unread,
Dec 21, 2023, 3:53:40 AM12/21/23
to Google Ads Scripts Forum
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);
    }
  }
}

Screenshot 2023-12-20 at 5.41.14 PM.png
Screenshot 2023-12-20 at 5.40.27 PM.png

Sigurd Fabrin

unread,
Dec 21, 2023, 7:48:29 AM12/21/23
to Google Ads Scripts Forum
The field is not available in the default api version. Try manually adding {apiVersion: 'v15'} to your query


Sigurd

Q Florence

unread,
Dec 21, 2023, 10:13:37 AM12/21/23
to Google Ads Scripts Forum
That worked. Thank you!

Google Ads Scripts Forum Advisor

unread,
Dec 21, 2023, 12:18:23 PM12/21/23
to adwords...@googlegroups.com
Thank you Sigurd for your suggestion to the user's query.

Hi,

Thank you for reaching out to the Google Ads Scripts support team.

We are glad to hear that the issue has been resolved at your end.

Kindly get back to us if you have any concerns related to the Google Ads Scripts. We are happy to help you.

 This message is in relation to case "ref:!00D1U01174p.!5004Q02r34b5:ref"

Thanks,
 
Google Logo Google Ads Scripts Team

 

Reply all
Reply to author
Forward
0 new messages