Filter by campaign name or campaign status

23 views
Skip to first unread message

Alexander Martel

unread,
Feb 20, 2023, 4:02:50 AM2/20/23
to Google Ads Scripts Forum
Hey guys,

I just startet to work with scripts and for that I am playing with this little script to get some data from kwIter.

function main() {
  var keywordSelector = AdsApp
     .keywords()
     .withLimit(10)
     .withCondition("Status = ENABLED")
     .withCondition("Impressions > 1")
     .forDateRange("YESTERDAY")
     .orderBy("Clicks DESC");
  var keywordIterator = keywordSelector.get();
  while (keywordIterator.hasNext()) {
    const keyword = keywordIterator.next();
    console.log(keyword.getText()+', Match Type: '+keyword.getMatchType()+', QS: '+keyword.getQualityScore()+', Current CPC: '+keyword.bidding().getCpc()+', 1st Page Bid: '+keyword.getFirstPageCpc()+', Abs. Top Bid: '+keyword.getTopOfPageCpc());
  }
}

Right now I have difficulties to filter the function by campaign status or campaign name. Can someone help me out?

Best Regards
Alex

Google Ads Scripts Forum Advisor

unread,
Feb 20, 2023, 6:30:51 AM2/20/23
to adwords...@googlegroups.com

Hi Alex,

I'm Kevin from the Google Ads Scripts team.

Upon checking, it appears that the resource names in your script is not yet migrated. In order to filter by campaign name/status, you will need to use the campaign.name and campaign.status fields. For additional reference, you may check out our Resource Mappings documentation to determine the new names of the fields that you're using. I also suggest that you utilize the Google Ads Query Builder tool for keyword_view to build your condition in the WHERE clause.

If you are still having issues, please further elaborate what you would like to achieve then provide your CID and script name so we can further investigate.

Regards,

Google Logo
Kevin Gil
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2j22Cy:ref
Reply all
Reply to author
Forward
0 new messages