Hello,
I was wondering if anyone could please assist me with a script for pausing ad groups based off of a list in a Google Sheet which is formatted with three columns with the headers 'Campaign', 'Ad Group', and 'Status'. When I run this script below, it tells me 'TypeError: Cannot find function pause in object true.-- Campaign: Campaign Name and ad group: Ad Group Name do not exist' even though the Campaign and Ad Groups do exist in the account:
function main() {
var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL).getSheetByName("Stuff to Pause Summary");
var data = spreadsheet.getRange("A3:C").getValues();
for(var i = 0; i < data.length; i++) {
var row = data[i];
if(row[0] == '')
break;
else {
try {
var status = row[2];
var ag = row[1];
var campaign = row[0];
var adGroup = AdsApp.adGroups().withCondition("Name = '" + ag + "'").withCondition("CampaignName = '" + campaign + "'").get().hasNext();
var pauseAdGroup = adGroup.pause();
Logger.log("We paused the following ad groups: " + pauseAdGroup);
}
catch(e) { Logger.log(e + "-- Campaign: %s and ad group: %s do not exist", row[0], row[1])}
}
}
}
Any help would be appreciated, thanks!