Forked from siliconvallaeys/Check for automatically added ads in AdWords.js
Created
February 1, 2017 18:07
-
-
Save adaminfinitum/c6553f5e4ec26a1b6546a3de444ec002 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
// AdWords Script: Check If Accounts Have Automatically Added Ads | |
// --------------------------------------------------------------- | |
// Copyright 2017 Optmyzr Inc., All Rights Reserved | |
// | |
// This MCC level AdWords Script reports which accounts have | |
// ads with the label "Added by AdWords", indicating that | |
// Google is automatically testing new ad variations. | |
// Users can then go to the impacted accounts and search for the | |
// label and decide whether or not to keep these new ads. | |
// | |
// For more PPC management tools, visit www.optmyzr.com | |
// | |
*/ | |
var EMAIL = ""; // Update this with your email address if you wish to get an email notification if an account is using automatically added ads | |
function main() { | |
var accountSelector = MccApp.accounts() | |
.withLimit(50); | |
// Process the account in parallel. The callback method is optional. | |
accountSelector.executeInParallel("checkForAutomaticallyAddedAds"); | |
} | |
function checkForAutomaticallyAddedAds() { | |
var accountId = AdWordsApp.currentAccount().getCustomerId(); | |
var labelIterator = AdWordsApp.labels().withCondition("Name = 'Added by AdWords'").get(); | |
if(labelIterator.hasNext()) { | |
var label = labelIterator.next(); | |
var adIterator = label.ads().withCondition("Status = ENABLED").get(); | |
var adCount = 0; | |
while(adIterator.hasNext()) { | |
var ad = adIterator.next(); | |
var campaignName = ad.getCampaign().getName(); | |
var adGroupName = ad.getAdGroup().getName(); | |
//Logger.log(campaignName + " - " + adGroupName); | |
adCount++; | |
} | |
Logger.log("account with ID " + accountId + " has " + adCount + " active automatically added ads."); | |
if(EMAIL) MailApp.sendEmail(EMAIL, "Account " + accountId + " has automatic ads", "This account has " + adCount + " automatically added ads. Go to the account and use the Labels feature to find them."); | |
} else { | |
Logger.log("account with ID " + accountId + " has NO active automatically added ads."); | |
//if(EMAIL) MailApp.sendEmail(EMAIL, "All clear for account " + accountId, "This account is NOT using automatically added ads."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment