Adwords Marketing & Custom Web Databases
  • HOME
  • RESULTS
  • Adwords Q&A Blog
  • ARTICLES
  • Blog
    • 2016-17 Work
    • 2013-14 Work
  • Experience
  • HUMOR
  • HOME
  • RESULTS
  • Adwords Q&A Blog
  • ARTICLES
  • Blog
    • 2016-17 Work
    • 2013-14 Work
  • Experience
  • HUMOR

Pause Adwords & Send an Email When Over a Cost Limit.

11/1/2017

 
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

    January 2018
    December 2017
    November 2017
    October 2017
    August 2017
    March 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015
    April 2015
    March 2015
    February 2015
    January 2015
    December 2014
    November 2014

    Categories

    All
    Adwords Remarketing
    Bidding
    Broad Match
    Call Conversions
    Disallow
    Display Ads
    Duplicate Keywords
    Holiday Ads
    Income Targeting
    Increase Traffic
    Keyword Planning
    Keyword Research
    Keywords
    Location Targeting
    Match Types
    Multi-channel Funnels
    Negative Match
    Nofollow
    Noindex
    Quality Score
    Remarketing Tags
    Reporting
    Segmentation
    Single Keyword Ad Group
    Skag
    Targeting Operating System
    Video Targeting

    Improve Your Sales, Marketing, and Operations

Submit
Contact Scott Business Research PPC at (888) 520-3644

Google Partners are agencies, marketing professionals, and online experts who have been certified by Google to manage AdWords accounts. Companies who qualify for Partner status earn the Google Partner badge.  We are experts at Insurance Marketing, San Diego Adwords Marketing & Management.
Picture

San Diego Adwords Management
✕