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 admin

Check Also

Next.js is a framework built on top of React and Node.js, offering several advantages over using React and Node.js separately

Simplified Setup: React.js requires manual configuration for features like server-side rendering (SSR), routing, and code …

Leave a Reply

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