Daily budget script

69 views
Skip to first unread message

Ain

unread,
Jun 25, 2020, 12:37:43 AM6/25/20
to Google Ads Scripts Forum
Hi, I'm trying to use this script but when I click on preview, it says 
Syntax error. (line 10) I've highlighted it

I'm no pro in scripts & it's my first few attempts too. Can I know where I'm doing wrong? or maybe didn't fill in?

function main(){
  var sheet = ss.getSheetByName("Copy of All Accounts");
  var range = sheet.getRange("C48");
  var cellValues = range.getValues();
 
  for (var i = 0; i < cellValues.length; i++) {    
   var campaignIterator = AdsApp.campaigns()
       .withCondition("Name = " + JSON.stringify(cellValues[i][0])); //The cellvalues[i][0] corresponds to the campaign names listed in the spreadsheet
       .get();

   while (campaignIterator.hasNext()) {
     var campaign = campaignIterator.next();
     campaign.getBudget().setAmount(cellValues[i][1]); //The cellvalues[i][1] is the corresponding amount budget of specific campaigns
     Logger.log('Campaign with name = ' + campaign.getName() +
 ' has budget = ' + campaign.getBudget().getAmount());
   }
  }
}

Google Ads Scripts Forum Advisor

unread,
Jun 25, 2020, 1:58:15 AM6/25/20
to adwords-scripts+apn2wqddsrljcdtl...@googlegroups.com, adwords-scripts+apn2wqddsrljcdtl...@googlegroups.co, adwords...@googlegroups.com
Hi Ain,

So our team can better investigate, could you provide your Customer ID and the name of the Script? You can send your reply using the Reply privately to author option.

Also, could you provide access to our team by allowing the Google.com group to have view access to the sheet?

Best regards,
Peter
Google Ads Scripts Team

ref:_00D1U1174p._5004Q219GXk:ref

Андрей Лебедев

unread,
Jan 13, 2022, 1:25:07 AMJan 13
to Google Ads Scripts Forum
good nights
I really need your help
in my account
67 campaigns
they have 223 ad groups
for all this goodness limited budget of $ 50 per day

all campaigns exceed the budget of $ 2, which I allocated $ 5 each

my client agrees that that campaign managed to get into the budget, and those who did not have time to spend will wait for a new day

but it is necessary to automate this whole thing, turn it off, and then turn it on in the morning

please help :) choose (if there is a ready-made solution, just change the daily budget and that's it) or make a script (so that I understand what's what and how)

четверг, 25 июня 2020 г. в 08:58:15 UTC+3, Google Ads Scripts Forum Advisor:
Reply all
Reply to author
Forward
0 new messages