Home / All Articles / How to exclude multiple zip code from adWords campaigns via script code and applied on account for all campaign?

How to exclude multiple zip code from adWords campaigns via script code and applied on account for all campaign?

Whole code CTRL+C and go to the editor and press CTRL + A after CTRL+V

 


function main() {
getAllCampaigns();
}
function getAllCampaigns() {
// AdsApp.campaigns() will return all campaigns that are not removed by
// default.
var campaignIterator = AdsApp.campaigns().get();
Logger.log('Total campaigns found : ' +
campaignIterator.totalNumEntities());
while (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();
Logger.log(campaign.getName());


// Exclude Tennessee, United States (location id = 21175) See
// https://developers.google.com/adwords/api/docs/appendix/geotargeting
// for list of all supported geo codes.
// You could pass either the location code, or a TargetedLocation or
// ExcludedLocation object from an existing campaign.
var zipcode_ides =[9013072,9013073,9013074];
//var tennessee_id = 21175;
zipcode_ides.forEach(function(val){
Logger.log(val);
campaign.excludeLocation(val);
//var sushil = campaign.excludeLocation(val);
// Logger.log(sushil);
});

}
}

After you will see the output like this

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 *