// ...
function excludeSpamPlacementsAtAdGroupLevel(){ var adGroupsIterator = AdWordsApp.adGroups() .withCondition("AdGroupStatus IN [ENABLED, PAUSED]") .withCondition("CampaignStatus IN [ENABLED, PAUSED]") .get(); while (adGroupsIterator.hasNext()){ var adGroup = adGroupsIterator.next();
Logger.log("Before excluding"); var excludeOperation = adGroup.display(); Logger.log("Before aux"); var aux = excludeOperation.newPlacementBuilder(); Logger.log("Before aux2"); var aux2 = aux.withUrl("test12345.com") Logger.log("Before aux3"); var aux3 = aux2.exclude(); Logger.log("After excluding");
// ...
I've located the error at newPlacementBuilder method, but I don't know why it happens.
var adGroupsIterator = AdWordsApp.adGroups()
.withCondition("AdGroupStatus IN [ENABLED, PAUSED]")
.withCondition("CampaignStatus IN [ENABLED, PAUSED]")
.withCondition("AdGroupType = 'DISPLAY_STANDARD'") // Specify AdGroupType
.get();
function excludeSpamPlacementsAtCampaignLevel(){ var campaignsIterator = AdWordsApp.campaigns()
.withCondition("CampaignStatus IN [ENABLED, PAUSED]")
.withCondition("AdNetworkType1 = 'CONTENT'") .get(); while (campaignsIterator.hasNext()){ var campaign = campaignsIterator.next();
Logger.log("Before excluding at Campaign level");
SPAM_LIST.forEach(function (placement_url) { Logger.log(placement_url); var excludeOperation = campaign.display().newPlacementBuilder().withUrl(placement_url).exclude(); Logger.log(placement_url + " excluded from " + campaign.getName() + " campaign"); });
Logger.log("After excluding at Campaign level"); } } // End of excludeSpamPlacementsAtCampaignLevel function