Here is a script that will pause an ad and send you an email if a campaign's cost is over a certain limit (which you specify). You will only need to modify the variables costLimit, adGroupId and adId. You will also need to fill in the details of your email address on the line MailApp.sendEmail("Your email address", "Your subject", "Your body"); function main() {
var costLimit = 3.20; var adGroupId = 22222; var adId = 11111; var report = AdWordsApp.report( 'SELECT CampaignName, CampaignId, Cost, HourOfDay ' + 'FROM CAMPAIGN_PERFORMANCE_REPORT ' + 'WHERE Cost > 0 ' + 'DURING TODAY'); var rows = report.rows(); while (rows.hasNext()) { var row = rows.next(); var campaignName = row['CampaignName']; var campaignId = row['CampaignId']; var hour = row['HourOfDay']; var cost = row['Cost']; Logger.log(campaignName + ',' + campaignId + ',' + cost + ',' + hour ); if(cost > costLimit){ var campaign = AdWordsApp.campaigns().withIds([campaignId]).get(); if(campaign.hasNext()){ var adIterator = AdWordsApp.ads().withIds([[adGroupId,adId]]).get(); if(adIterator.hasNext()){ var ad = adIterator.next(); ad.pause(); MailApp.sendEmail("Your email address", "Your subject", "Your body"); } } } } } Comments are closed.
|
Archives
December 2017
Categories
All
|