Remove Location Targets in Bulk - Google Ads Scripts
After exhausting all options, I'm hoping for some help. I am trying to adjust my script to remove all targeted locations for a specific campaign. The problem is, the only way I've found to do it is to iterate through each targeted location and remove them one by one. If a campaign has 2000 location targets, this takes far too long and the script times out.
Below is an example of the standard script used to remove them one by one. Any suggestions on how to speed this up? Is it possible to pass an array of campaign specific locationIDs in and have it remove them all in one shot? Or, is there a function available to remove ALL locations at once? Either of these methods would work for me but I haven't been able to find a solution that accomplishes this.
Thanks in advance for your help
function removeTargetedLocations(campaign) { var campaignIterator = AdWordsApp.campaigns() .withCondition('Name = ' + campaign + '') .get(); if (campaignIterator.hasNext()) { var campaign = campaignIterator.next(); var locationIterator = campaign.targeting().targetedLocations().get(); while (locationIterator.hasNext()) { var loc = locationIterator.next(); loc.remove(); } } }