When you manage multiple accounts, you do not always have time to check every day that all your campaigns are still active. Sometimes, for various reasons, campaigns may stop temporarily. To prevent this from happening after a few days, we have created a script that automatically alerts you. If a campaign has not generated any impressions the day before, you will receive an email at the email address you set.

Settings

In the config section of the script, you can adjust multiple values ​​as desired.

  • LOG: Change this to 'true' to see what exactly happened. Leave on 'false' when the script is really running, because that's faster.
  • EMAIL: Enter the e-mail address where you want to receive the notification. You can enter multiple email addresses by separating them with a comma.
  • EMAIL_INTRO: This is the message at the top of the email. This can be adjusted as desired.
  • EMAIL_SUBJECT: The subject of the email.

MCC level

The following script can be used at MCC level, so that you have an overview of campaigns that are silent in 1 email.

Scheduling: Run this script 1x per day, preferably in the morning, because then you know when you sit behind your desk.

Script
// Copyright 2019. Increase BV. All Rights Reserved.
// Not to be used without permission of the creator or Increase B.V.
//
// Created By: Tibbe van Asten
// for Increase B.V.
// 
// Last update: 19-02-2019
//
// ABOUT THE SCRIPT
// With this script you keep track of impressions in campaigns.
// When a campaign didn't receive any impressions yesterday,
// the script will send an email.
// ------------------------------------------------------------

// Script settings
var config = {
  LOG : false,      			// Default: false. Set to true when you want to see why changes are made
  EMAIL : "This email address is being protected from spambots. You need JavaScript enabled to view it.",     // The emailaddress the noticed will be send to, separated by comma.
  EMAIL_INTRO : "De volgende BING campagnes hebben vandaag nog geen vertoningen ontvangen!<br /><br />",
  EMAIL_SUBJECT : "WARNING: BING campagnes zonder vertoningen",
  EMAIL_FROM : "This email address is being protected from spambots. You need JavaScript enabled to view it.",
  DATE_RANGE : "TODAY",

  // Get your own SendGrid API Key from https://app.sendgrid.com/settings/api_keys
  SENDGRID_API_KEY : "SG.XYZ"

}

// ------------------------------------------------------------

function main() {
  
  var emailContent = config.EMAIL_INTRO;
  
  var accountIterator = AccountsApp
  	.accounts()
  	.get();
  
  while(accountIterator.hasNext()){
    var account = accountIterator.next();
    AccountsApp.select(account);
    
    	if(config.LOG === true){
          Logger.log("Account: " + account.getName());
        }

    var campaignIterator = BingAdsApp
    	.campaigns()
    	.withCondition("Status = ENABLED")
    	.withCondition("Impressions = 0")
    	.forDateRange(config.DATE_RANGE)
    	.get();
    
    while(campaignIterator.hasNext()){
      var campaign = campaignIterator.next();      

      	if(config.LOG === true){
          Logger.log("Campaign: " + campaign.getName());
        }
      
      emailContent += account.getName() + " " + campaign.getName() + "<br />";
      
    } // campaignIterator    
    
    if(config.LOG === true){
      Logger.log("----");
    }
    
  } // accountIterator
  
  sendEmail(emailContent);
  Logger.log("Email send");
  
} // function main()

// ------------------------------------------------------------

function sendEmail(emailContent) {

    var headers = {
        "Authorization" : "Bearer "+config.SENDGRID_API_KEY 
    }
    var email = {"personalizations": [{"to": [{"email": config.EMAIL}]}],"from": {"email": config.EMAIL_FROM},"subject": config.EMAIL_SUBJECT,"content": [{"type": "text/html", "value": emailContent}]};
  
    var options = {
        contentType: 'application/json',    
        'muteHttpExceptions': true, 
        'method':'post',
        'headers':headers,
        'payload':JSON.stringify(email)
    }

    var response = UrlFetchApp.fetch('https://api.sendgrid.com/v3/mail/send', options); 

} // function sendEmail()

Sharing knowledge

Adsscripts.com is all about sharing knowledge. In the current market, PPC specialists like to keep their knowledge and experience to themselves. We're convinced that sharing knowledge can ensure that everyone gets better at their work. We want to change this by sharing our knowledge about scripts with everyone.

Do you also want to contribute? We are open to new ideas and feedback on everything you find on Adsscripts.com.

Contact us

Nils Rooijmans
Google Ads Scripter
Water Cooler Topics
Nils Rooijmans, Google Ads Scripter
Bas Baudoin
Teamleader PPC
Happy Leads
Bas Baudoin, Teamleider SEA
Tibbe van Asten
PPC Specialist
Founder Adsscripts
Tibbe van Asten, Senior PPC Automation Specialist