Google Ads Scripts Beta Sample

178 views
Skip to first unread message

Misty Harper

unread,
Jul 29, 2021, 2:54:12 PM7/29/21
to Google Ads Scripts Forum
Good afternoon,

I'm starting to test the new Google Ads scripts that are in beta, and the sample at 
 
function main() {
   let keywords = AdsApp.keywords()
         .orderBy("metrics.impressions DESC")
         .forDateRange("YESTERDAY")
         .withLimit(10)
         .get();

   console.log("The 10 keywords with the most impressions yesterday:");
   while (keywords.hasNext()) {
       let keyword = keywords.next();
       console.log(`${keyword.getText()}: ${keyword.getStatsFor("YESTERDAY").getImpressions())}`);
     }
}



Gives this error:
SyntaxError: Missing } in template expression (line 11)

When I remove the last ) from after .getImpressions() the script works:

function main() {
   let keywords = AdsApp.keywords()
         .orderBy("metrics.impressions DESC")
         .forDateRange("YESTERDAY")
         .withLimit(10)
         .get();

   console.log("The 10 keywords with the most impressions yesterday:");
   while (keywords.hasNext()) {
       let keyword = keywords.next();
       console.log(`${keyword.getText()}: ${keyword.getStatsFor("YESTERDAY").getImpressions()}`);
     }
}

Just wanted to mention in case that sample script page needs an edit. 

Best,
Misty Harper
sample google ads script beta 7.29.2021.png

Google Ads Scripts Forum Advisor

unread,
Jul 30, 2021, 1:39:03 AM7/30/21
to adwords...@googlegroups.com
Hi Misty,

Thank you for proactively notifying us. We've updated our document page with the details that you mentioned here.

Regards,
Google Logo
Teejay Wennie Pimentel
Google Ads Scripts Team
 


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