The script is not working properly recently !

124 views
Skip to first unread message

Afrak Co

unread,
Mar 29, 2020, 8:13:50 AM3/29/20
to Google Ads Scripts Forum
Greetings,

Hope you are doing well.
We have a Google Accounts Manager account ( MCC ) and Google Partner.
Because we are from billing UAE, so there is an automatic payment system. So we have been using the following script in order to make it easier to manage our customer accounts ( Child Accounts ) with the Google Payments System in recent months.
But lately the script is not working properly, but it should be noted that there is no error.


 

function main() {var costReport = AdWordsApp.report("Select Cost from ACCOUNT_PERFORMANCE_REPORT");  var reportRow = costReport.rows().next(); var totalCost = reportRow["Cost"].replace(',', '');

if (totalCost > 200){  var campaignIterator = AdWordsApp.campaigns().withCondition("Status = ENABLED").get(); while (campaignIterator.hasNext()){ var campaign = campaignIterator.next();campaign.pause();}}}


Could you please help us !?

Thanks,
Afrak Co

Google Ads Scripts Forum Advisor

unread,
Mar 29, 2020, 9:42:29 PM3/29/20
to adwords...@googlegroups.com
Hi Afrak,

Thanks for posting your concern. I would be happy to provide support to your concern.

To further investigate the issue, could you provide more details on how the script is not working properly? Also, it would be helpful if you can provide the customer ID and the name of the script via Reply privately to author option?

Regards,
Ejay
Google Ads Scripts Team

ref:_00D1U1174p._5001UZV0q1:ref
Message has been deleted

Google Ads Scripts Forum Advisor

unread,
Apr 5, 2020, 11:39:00 PM4/5/20
to adwords...@googlegroups.com
Hi AfrakCo,

Thanks for providing the requested information.

This is a known issue that our team is still working on for the long term fix. As a workaround for this issue, could you try the following instructions below?

1. Go to accounts.google.com.
2. Go to "Security" in left-nav.
3. Go to "Third-party apps with account access" and click "Manage third-party access".
4. Find the name of the problematic script, click it, and then click "REMOVE ACCESS".
5. Then go back to the UI, which encounter the error, and it should prompt you for auth (for all relevant scopes).

Let me know if you have questions with the provided suggestion.

Afrak Co

unread,
Apr 7, 2020, 4:31:24 AM4/7/20
to Google Ads Scripts Forum
Hi Ejay,

Thank you so much for taking time and sending me this. We have examined what you said and it was useful for one single account. But the thing is that we are managing so many different child accounts under our MCC and it gets really challenging for us to control their balance one by one and not letting them pass their threshold.  
  • Please provide us with information about how we can manage our child accounts balance and prevent them to pass their threshold. Maybe you can kindly help us with finding another useful script which can be implemented to our MCC.

  • The next concern is that the mentioned script does not function for Video and App universal campaigns. I wonder if there is any other budget script which works for app and video campaigns and stop them after their spend their budgets. 


I look forward to you answer eagerly.

Best
AfrakCo Ltd

Google Ads Scripts Forum Advisor

unread,
Apr 7, 2020, 6:00:56 AM4/7/20
to adwords...@googlegroups.com
Hi,

I am happy to know that the provided suggestion worked.

With regard to your current concern, you may refer to the updated script below and you may preview it at the MCC account to see if it will work on your end. I just implemented the MCC script so that it will iterate all the accounts and pause all the campaigns when threshold met. So that it will also process video campaigns, I have implemented what is specified on this guide. However, Universal App campaign type is currently not supported on Google Ads scripts and so this script as well.
function main() {

  var accountIterator = AdsManagerApp.accounts()
      .get();

  var managerAccount = AdsApp.currentAccount();
  while (accountIterator.hasNext()) {
    var account = accountIterator.next();

    AdsManagerApp.select(account);

    var costReport = AdWordsApp.report("Select Cost from ACCOUNT_PERFORMANCE_REPORT");  
    var reportRow = costReport.rows().next(); 
    var totalCost = reportRow["Cost"].replace(',', '');

    if (totalCost > 'INSERT_THRESHOLD'){  

       var campaignIterator = AdWordsApp.campaigns().withCondition("Status = ENABLED").get(); 
        while (campaignIterator.hasNext()){ 
          var campaign = campaignIterator.next();
          campaign.pause();
       }
       var videoCampaignSelector = AdsApp
           .videoCampaigns()
           .withCondition("Status = ENABLED");

       var videoCampaignIterator = videoCampaignSelector.get();
       while (videoCampaignIterator.hasNext()) {
         var videoCampaign = videoCampaignIterator.next();
         videoCampaign.pause();
       }
    }
  }
}


Hope this helps. Let me know if you have further questions.

Afrak Co

unread,
Apr 8, 2020, 2:12:44 AM4/8/20
to Google Ads Scripts Forum
Dear Ejay

Thank you so much for the script.We are more than happy that you just get what we need cause we have been searching it for a long time. Implementing the script on a child account and on MCC there were two different errors. It would be great if you could take a look at the errors and let us know what we can do to fix them and make the MCC managing an easier thing to do. Attached you can see screenshots showing the errors.

Note: As we have some manual payment account, what kind of influence has this script on them?  

I look forward to hearing from you soon. 

Kind Regards

AfrakCo Ltd
Script on MCC.jpg
Script n child account.jpg

Google Ads Scripts Forum Advisor

unread,
Apr 8, 2020, 4:25:38 AM4/8/20
to adwords...@googlegroups.com
Hi,

With regard to the 'ReferenceError: "AdsManagerApp" is not defined', the reason why this error occurred is because the updated script was executed at the child account. Please note that the updated script could only be executed at MCC level.

As for the second error and to further investigate, could you provide the customer ID and the name of script via Reply privately to author option?

Moving forward to the question below, the possible influence of this script to your account is to lower the cost that will generate as it will pause campaigns.

"As we have some manual payment account, what kind of influence has this script on them? "

Afrak Co

unread,
Apr 13, 2020, 12:54:33 AM4/13/20
to Google Ads Scripts Forum
Greetings,

Did you receive our message !?
Because we have't any response from your side for 5 days !

Thanks 

Kyle Wilson

unread,
Jan 11, 2022, 1:10:17 AMJan 11
to Google Ads Scripts Forum
Did this issue end up getting resolved? I'm hoping to accomplish this same thing in our own Manager (MCC) account.
Reply all
Reply to author
Forward
0 new messages