Home / All Articles / How to removed exclude location to the all campaign via scripts

How to removed exclude location to the all campaign via scripts


function main() {
removeExcludelocation();
}
function removeExcludelocation() {
var campaignIterator = AdsApp.campaigns().get();
Logger.log('Total campaigns found : ' +
campaignIterator.totalNumEntities());
while (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();
Logger.log(campaign.getName());
var locationIterator = campaign.targeting().excludedLocations().get();
var ids = [9013072,9013073];
while (locationIterator.hasNext()) {
var excludedLocation = locationIterator.next();
Logger.log('Location id: ' + excludedLocation.getId().toFixed(0) +
', ZIP Code: ' + excludedLocation.getName() + ', Country code: ' +
excludedLocation.getCountryCode());
if (ids.indexOf(excludedLocation.getId()) != -1) {
excludedLocation.remove();
}
}

}
}

About Sushil Kumar

Check Also

What is higher order function in JavaScript?

A higher-order function is a function that either takes another function as an argument or …

Leave a Reply

Your email address will not be published. Required fields are marked *