-
-
Save neeksor/f77a2f7603273d2cf4bb4505cb8364b4 to your computer and use it in GitHub Desktop.
AdWords Negative Match Placements Term
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Removes placements containing string | |
* Exclusions are per campaign. | |
* single account - no mcc support. | |
* badPatterns = csv list of words to filter. | |
* ex: | |
* var badPatterns = 'meowshareen, someotherspam'; | |
*/ | |
function main() { | |
// csv list of words | |
var badPatterns = 'meowshareen'; | |
badPatterns.split(',').map(function (s) {return s.trim();}) | |
.forEach(function (domain) { | |
var placementSelector = AdWordsApp.display().placements().withCondition("PlacementUrl CONTAINS '" + domain + "'").withCondition("CampaignStatus != REMOVED"); | |
var placementIterator = placementSelector.get(); | |
while (placementIterator.hasNext()) { | |
var placement = placementIterator.next(); | |
var placementUrl = placement.getUrl(); | |
Logger.log("Matching URL: " + placementUrl); | |
var campaign = placement.getCampaign(); | |
var excludeOperation = campaign.display().newPlacementBuilder().withUrl(placementUrl).exclude(); | |
if (!excludeOperation.isSuccessful()) { | |
Logger.log("Could not exclude : " + placementUrl); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment