Hi
I have made a script to check if all active ad groups have active keywords and if not should export the ad groups with missing keywords to a Google sheet.
But when it runs it often says it "Failed due to system errors" and gives this error message:
I don't know why it does this, i have asked around, and i have been told that is might be a runtime error. And that it could have something to do with the syntax loop. But i don't know how to fix it.
The script looks like this:
/**********************
Keyword Checker
**********************/
var SPREADSHEET_URL = 'INSERT SHEET URL HERE';
var Sheet_name = 'INSERT SHEET NAME HERE';
function main() {
var sheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL).getSheetByName(Sheet_name);
var range = sheet.getRangeList(['A1:A', 'B1:B'])
range.clearContent();
sheet.getRange("A1").setValue("Campaign");
sheet.getRange("B1").setValue("Ad groups");
var GetAdGroups = AdWordsApp.adGroups()
.withCondition('Status = ENABLED')
.withCondition('CampaignStatus = ENABLED')
.withCondition("AdvertisingChannelType = SEARCH")
.withCondition("CampaignName DOES_NOT_CONTAIN_IGNORE_CASE 'dsa'")
.withCondition("AdGroupName DOES_NOT_CONTAIN_IGNORE_CASE 'dsa'")
.withCondition("campaign.experiment_type = BASE")
.get();
for (var row = 2; GetAdGroups.hasNext(); row ++) {
var AdGroups = GetAdGroups.next();
var KeywordCount = AdGroups.keywords().withCondition('Status = ENABLED').get().totalNumEntities();
if ((KeywordCount < 1)) {
sheet.appendRow( [AdGroups.getCampaign().getName(), AdGroups.getName()] );
}
}
}