Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
104 lines (82 sloc) 3.74 KB
/**
* This MCC level script removes Display placements with Super High CTR AND no view through conversions AND no conversions
* (you can edit these values on the top level variables).
* If one of the placements detected is anonymous.google, the script doesn't exclude it
*
* @author Alberto Esteves
* URL: http://www.albertoestevescorreia.com/adwords-script-eliminar-ubicaciones-display-spam/
*
* Inspired by:
*
* Dawson Reid
* Andrew Breen
*/
var impressionsMinimum = 2; // Select Display placements which have at least that number of impressions
var maxCtr = 0.49; // Select Display placements which have at least that Click Through Rate percentage
var conversionsLimit = 0; // Select Display placements which have no more than that number of conversions
var ViewThroughConversionsLimit = 0; // Select Display placements which have no more than that number of post-impression conversions
var mccLabelText = "no label"; // Filter AdWords accounts which have a MCC Account label
// If you don't want to filter by any MCC label, DO NOT make any change in this text
var timePeriod = "ALL_TIME"; // Period of time to analyze. You can choose another value according to https://developers.google.com/adwords/scripts/docs/reference/adwordsapp/adwordsapp_campaignselector?hl=es-419#forDateRange_1
// -------------------------------------------------------
function removeLowPerformanceDisplayPlacements (placementSelector) {
var placementIterator = placementSelector.get();
var adGroup, excludeOperation, placement, placementUrl;
while (placementIterator.hasNext()) {
placement = placementIterator.next();
placementUrl = placement.getUrl();
// Logger.log(placementUrl);
if (placementUrl != 'anonymous.google') {
adGroup = placement.getAdGroup();
excludeOperation = adGroup.display().newPlacementBuilder().withUrl(placementUrl).exclude(); // Exclude Display placement detected
if (!excludeOperation.isSuccessful()) {
Logger.log("Could not exclude : " + placementUrl);
}
} else {
Logger.log("Don't exclude anonymous.google.com !");
}
} // End of While
} // End of removeLowPerformanceDisplayPlacements function
function run () {
var placementSelector = AdWordsApp.display().placements()
.withCondition("Ctr > "+maxCtr)
.withCondition("Impressions >= "+impressionsMinimum)
.withCondition("Conversions <= "+conversionsLimit)
.withCondition("ViewThroughConversions <= "+ViewThroughConversionsLimit)
.withCondition("CampaignStatus != REMOVED")
.forDateRange(timePeriod);
removeLowPerformanceDisplayPlacements(placementSelector);
} // End of run function
function executeInSequence (sequentialIds, executeSequentiallyFunc) {
// Logger.log('Executing in sequence : ' + sequentialIds);
sequentialIds.forEach(function (accountId) {
var account = MccApp.accounts().withIds([accountId]).get().next();
MccApp.select(account);
executeSequentiallyFunc();
});
} // End of executeInSequence function
function main () {
try {
var accountIterator;
if (mccLabelText != "no label") { // Filter accounts by MCC label
accountIterator = MccApp.accounts().withCondition("LabelNames CONTAINS '" + mccLabelText +"'").orderBy('Name').get();
} else { // Execute script for all accounts
accountIterator = MccApp.accounts().orderBy('Name').get();
}
var accountIds = [];
var accountId;
while (accountIterator.hasNext()) {
accountIds.push(accountId);
accountId = accountIterator.next().getCustomerId();
}
accountIds.push(accountId);
var sequentialIds = accountIds.slice(0);
if (accountIds.length > 0) {
executeInSequence(sequentialIds, run);
}
} catch (exception) {
// not an Mcc
Logger.log('Running on non-MCC account.');
run();
}
}
You can’t perform that action at this time.