Script "fails" without any logs or errors

320 views
Skip to first unread message

Nikolai Wiskow

unread,
May 6, 2022, 3:42:20 AM5/6/22
to Google Ads Scripts Forum
Hi Google Ads Team,

I have a script that, after switching to the new Scripts experience, runs for about 5 seconds, and then finishes /fails, but without logging any errors or even info.

I've tried using Logger.log and console.log to at least see how far the script gets, but even that produces no output.

It's clear that this script will need some adjustments, as it uses a lot of AWQL queries, however it would obviously much easier to debug if there was some output.

Can you please help me with this?

Best,
Nikolai

Google Ads Scripts Forum Advisor

unread,
May 9, 2022, 11:27:37 PM5/9/22
to adwords...@googlegroups.com

Hello Nikolai,

I’m James from the Google Ads scripts support team. Thank you for reaching out to us.

Can you please provide us with the following information below so that we can further investigate?

  • Google Ads account ID / CID
  • Script name

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2aR5DZ:ref

Nikolai Wiskow

unread,
May 11, 2022, 3:58:05 AM5/11/22
to Google Ads Scripts Forum
Hi James,

sure. The CID is 895-277-9911 and the script name is "Account Audit Script Test".

Thanks,
Nikolai

Google Ads Scripts Forum Advisor

unread,
May 13, 2022, 1:52:11 AM5/13/22
to adwords...@googlegroups.com
Hi Nikolai,

I work along with James. Thank you for providing the requested information.

I've checked the script in question, and was able to find the reason why it is not working on the new experience. The said script still uses the AdWords API reports. In order for the said script to work on the new experience, you will need to migrate the said report to Google Ads API. You may use this query migration tool to translate AWQL queries into GAQL.

Regards,
Google Logo
Teejay Wennie
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2aR5DZ:ref

Nikolai Wiskow

unread,
May 13, 2022, 2:19:56 AM5/13/22
to Google Ads Scripts Forum
Hi Teejay,

thank you for your answer. Is it normal behaviour that the unsupported AWQL query wouldn't raise an error in the new experience?

Best,
Nikolai

Google Ads Scripts Forum Advisor

unread,
May 16, 2022, 10:36:11 PM5/16/22
to adwords...@googlegroups.com
Hi Nikolai,

You should be able to see an error at runtime while previewing the script. 

Nikolai Wiskow

unread,
May 18, 2022, 4:22:34 AM5/18/22
to Google Ads Scripts Forum
That's exactly the problem - I see nothing at all. The script runs for about 4-5 seconds and then just aborts without logging anything, making it extremely hard to debug.

Google Ads Scripts Forum Advisor

unread,
May 19, 2022, 5:48:21 AM5/19/22
to adwords...@googlegroups.com
Hi Nikolai,

Thank you for pointing this out.

I just tested right now the running our sample legacy report on new experience and I didn't encounter an error. We're also sees reports that others sees scripts runs successfully on new experience while using AdWords API reports, but getting an empty data. One thing's for sure which is the depreciation of the legacy script. Once it was deprecated, scripts running on it will surely resulted an error. With that all said, we recommend our users to migrate their scripts to new experience.

Zunair Fayaz

unread,
Jun 7, 2022, 1:22:55 AM6/7/22
to Google Ads Scripts Forum
Hi!

I am having the issue where there is no errors but I don't get any result.
All of these output with 0. We have been running ads for over 3 months.

  var campaignIterator = AdsApp.campaigns().withCondition("campaign.status = ENABLED").get();
  var enabledCampaigns = campaignIterator.totalNumEntities();
  Logger.log('Enabled Campaigns:'+enabledCampaigns);

  var ads = AdsApp.ads();
  console.log(ads.get().totalNumEntities());
 
  var campaigns = AdsApp.campaigns();
  console.log(campaigns.get().totalNumEntities());
 
  var keywords = AdsApp.keywords()
    .withCondition('Clicks > 10')
    .forDateRange('LAST_MONTH')
    .get();
  console.log(keywords.totalNumEntities());


509-490-7956 "Google Ads Test"

Google Ads Scripts Forum Advisor

unread,
Jun 7, 2022, 6:00:41 AM6/7/22
to adwords...@googlegroups.com

Hello Zunair,

It appears that you have already raised this issue on a separate thread that you have created in our private channel, and I believe that I have already addressed this issue. Having said that, let me reiterate my response for better visibility.

Upon checking with the given testing code, I observed that your script implementation is fine. However, I took a closer look at your campaignads and keyword, and I observed that you’re using video campaignsresponsive video ads and video keywords which can’t be retrieved using the selectors that you declared in your script. That’s the main reason why you’re retrieving 0 data upon executing your script.

Having said that, I suggest that you use 
VideoCampaignSelector to retrieve your video campaigns, VideoAdSelector to retrieve your responsive video ads and VideoKeywordSelector to retrieve your video keywords. See sample code implementation below.

function main() {
var campaignIterator = AdsApp.videoCampaigns().withCondition("campaign.status = ENABLED").get();
var enabledCampaigns = campaignIterator.totalNumEntities();
Logger.log('Enabled Campaigns: '+enabledCampaigns);

var ads = AdsApp.videoAds().get();
console.log('Ads: '+ ads.totalNumEntities());

var campaigns = AdsApp.videoCampaigns();
console.log('Campaigns: '+campaigns.get().totalNumEntities());

var keywords = AdsApp.videoTargeting()
.keywords()
.forDateRange('LAST_MONTH')
.get();
console.log('Keywords: '+keywords.totalNumEntities());
}

Can you please try it on your end and let me know if you have any questions.

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2aR5DZ:ref

Nikolai Wiskow

unread,
Jun 24, 2022, 3:30:54 AM6/24/22
to Google Ads Scripts Forum
Ok, I keep having these problems where scripts will just not log anything and run forever, where before they finished in a matter of seconds.

Could you please look into this one?



var LABEL_FILTER = "BM_";

var SPREADSHEET_URL = "https://docs.google.com/spreadsheets/d/1czKFh8eEVGCqzvu7mxuCkiCYGoHi_qA3i28Y8OY3g2I/edit#gid=568195611";

var TARGET_SHEET = "Daten";
 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// MCC LOGIC - DON'T TOUCH FROM HERE ON
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var STATS_PER_ACC = {};

function main() {  
 
  var label_iter = AdsManagerApp.accountLabels().withCondition("Name CONTAINS " + LABEL_FILTER).get();
 
  var accs = [];
 
  while(label_iter.hasNext()) {
      var label = label_iter.next();
    var label_name = label.getName();
    var accounts = label.accounts().get();
   
    accs.push({
        labelName: label_name,
        accountSelector: accounts  
    });
  }
 
  for(i=0; i<accs.length; i++) {
    var obj = accs[i];
    var accounts = accs[i].accountSelector;
   
    while(accounts.hasNext()) {
     
       var account = accounts.next();
       var stats_month = account.getStatsFor("THIS_MONTH").getCost();
       var stats_yesterday = account.getStatsFor("YESTERDAY").getCost();

       var output = {
         accountId: account.getCustomerId(),
         accountName: account.getName(),
         statsMonth: stats_month,
         statsYesterday: stats_yesterday,
         label: obj.labelName  
       }

       if(!STATS_PER_ACC[output.accountId]) {
         STATS_PER_ACC[output.accountId] = output;
       } else {
         STATS_PER_ACC[output.accountId].label = STATS_PER_ACC[output.accountId].label + ", " + output.label
       }
    }
  }// end of for()
 
  Logger.log(STATS_PER_ACC);
  exportToSheet(SPREADSHEET_URL);
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EXPORT TO SPREADSHEET
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function exportToSheet(url) {

  var SS = SpreadsheetApp.openByUrl(url);
  var sheet = SS.getSheetByName( TARGET_SHEET);
 
  var data = [];
  var keys = Object.keys(STATS_PER_ACC);
   
  keys.map(function(e) {
    var element = STATS_PER_ACC[e];
    var row = [element.accountId, element.accountName, element.label, element.statsMonth, element.statsYesterday]
   
    if(data.indexOf(row) === -1) {
      data.push(row);
    }
  });

  var data_range = sheet.getRange(2, 1, data.length, data[0].length);
  sheet.getRange(2, 1, sheet.getLastRow(), data[0].length).clearContent();
  data_range.setValues(data);
}

Petra Manos

unread,
Jun 24, 2022, 3:50:49 AM6/24/22
to Google Ads Scripts Forum
I'm also pretty frustrated with the error reporting. Even when there is an error reported on the beta experience, it does not give you the line number of the error in the script which makes it a pain to debug.

I have had some of these silent failures as well, so I did a Logger output every few lines until I isolated the problem.

Another thing you can try doing is commenting out all of your script except for the beginning, and then gradually releasing some of the part that is commented out until the blank debug issue happens again, and then t can give you a bit of a guess as to where the problem is.

Nikolai Wiskow

unread,
Jun 24, 2022, 8:34:44 AM6/24/22
to Google Ads Scripts Forum
Thank you for your reply, Petra!

I followed your advice and commented out everything except the function main and a little console.log("here") - and still nothing.

I then copied the whole script into another MCC, ran it and it worked as expected. Which lead me to believe that maybe creating a fresh instance of this script in the other MCC might do the trick, and indeed, after creating a new script & copy pasting the code, it ran as expected.

Google Ads Scripts Forum Advisor

unread,
Jun 26, 2022, 11:16:26 PM6/26/22
to adwords...@googlegroups.com
Hi Nikolai,

Thank you for sharing your investigation findings and I'm glad that the issue is now resolved on your end. It is indeed that recreating the script in question fixes the issue which is also reported by other users as well.

Regards,
Google Logo
Teejay Wennie
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2aR5DZ:ref

Google Ads Scripts Forum Advisor

unread,
Jun 26, 2022, 11:23:35 PM6/26/22
to adwords...@googlegroups.com
Hi Petra,

I understand the inconvenience of the Google Ads Scripts new experience error logging. The team is currently working on this. We would request for your patience during this time.

Regards,
Google Logo
Teejay Wennie
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2aR5DZ:ref

Google Ads Scripts Forum Advisor

unread,
May 5, 2023, 3:27:00 AM5/5/23
to adwords...@googlegroups.com

Hi Petra,

 

Just circling back to this thread. I'd like to inform you that the error messages have been fixed to provide more information on where the issue or error is located once one occurs.

 

Let us know if we can assist you with anything else.

 

Best regards,

 

Google Logo Google Ads Scripts Team


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