Report campaign without impressions

Do you want to make sure that all your campaigns are still active? With this script you automatically receive an e-mail when a campaign has not generated any impressions the day before.

Start Now!
Report campaign without impressions
Report Get started!

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.

The 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.
// 
// Created: 23-08-2018
// Last update: 10-07-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.
//
////////////////////////////////////////////////////////////////////

var config = {
  
  LOG : true,
  
  EMAIL : "yourem@il.com",
  EMAIL_INTRO : "The following campaigns have no impressions today!<br />",
  EMAIL_SUBJECT : "WARNING: Campaigns without impressions",
  
  DATE_RANGE : "TODAY",
  COMPARE : true,
  COMPARE_DATERANGE : "LAST_7_DAYS",
  ACCOUNT_LABEL : "Active"
  
}

////////////////////////////////////////////////////////////////////

function main() {
  
  var emailContent = config.EMAIL_INTRO;
  
  var accountIterator = MccApp
  	.accounts()
  	.withCondition("LabelNames CONTAINS '" + config.ACCOUNT_LABEL + "'")
  	.get();
  
  while(accountIterator.hasNext()){
    var account = accountIterator.next();
    MccApp.select(account);

    var campaignIterator = AdsApp
    	.campaigns()
    	.withCondition("Status = ENABLED")
    	.withCondition("Impressions = 0")
    	.withCondition("CampaignExperimentType = BASE")
    	.withCondition("ServingStatus = SERVING")
    	.forDateRange("TODAY")
    	.get();
    
    	  //Add accountname as heading in email
        if(campaignIterator.hasNext()){
          emailContent += "<br /><b>" + account.getName() + "</b><br />";
          
          if(config.LOG === true){
            Logger.log("Account: " + account.getName());
          }
        }
    
    while(campaignIterator.hasNext()){
      var campaign = campaignIterator.next(); 
      
      // Only add campaigns with > 0 impressions previous period
      if(config.COMPARE === true){
        
        // Check for impressions previous period
        if(campaign.getStatsFor(config.COMPARE_DATERANGE).getImpressions() > 0){
          
          if(config.LOG === true){
            Logger.log("Campaign: " + campaign.getName());
          }
          
          emailContent += campaign.getName() + "<br />";
          
        }
        
      } // compare with previous period
      else {
        
        if(config.LOG === true){
          Logger.log("Campaign: " + campaign.getName());
        }
      
        emailContent += campaign.getName() + "<br />";
        
      } 
      
    } // campaignIterator    
    
    var shoppingCampaignIterator = AdsApp
      .shoppingCampaigns()
      .withCondition("Status = ENABLED")
      .withCondition("Impressions = 0")
      .withCondition("CampaignExperimentType = BASE")
      .withCondition("ServingStatus = SERVING")
      .forDateRange("TODAY")
      .get();
    
    //Add accountname as heading in email
    if(shoppingCampaignIterator.hasNext() && !campaignIterator.hasNext()){
      emailContent += "<br /><b>" + account.getName() + "</b><br />";
      
      if(config.LOG === true){
        Logger.log("Account: " + account.getName());
      }
    }
    
    while(shoppingCampaignIterator.hasNext()){
      var campaign = shoppingCampaignIterator.next();      

      // Only add campaigns with > 0 impressions previous period
      if(config.COMPARE === true){
        
        // Check for impressions previous period
        if(campaign.getStatsFor(config.COMPARE_DATERANGE).getImpressions() > 0){
          
          if(config.LOG === true){
            Logger.log("Campaign: " + campaign.getName());
          }
          
          emailContent += campaign.getName() + "<br />";
          
        }
        
      } // compare with previous period
      else {
        
        if(config.LOG === true){
          Logger.log("Campaign: " + campaign.getName());
        }
      
        emailContent += campaign.getName() + "<br />";
        
      } 
      
    } // shoppingCampaignIterator    
    
    if(config.LOG === true){
      Logger.log("----");
    }
    
  } // accountIterator
  
  sendEmail(emailContent);
  Logger.log(emailContent);
  
} // function main

////////////////////////////////////////////////////////////////////

function sendEmail(emailContent) {
  
  MailApp.sendEmail({
    to: config.EMAIL,
    subject: config.EMAIL_SUBJECT,
    htmlBody: emailContent});
  
} // function sendEmail
Show whole script!
The Experts
Tibbe van Asten Head of PPC @ Increase
Nils Rooijmans Water Cooler Topics
Martijn Kraan Freelance PPC Specialist
Bas Baudoin Teamlead SEA @ Happy Leads
How about you? JOIN US!
Sharing Knowledge
Caring

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

Training &
Workshop
Contact us!
Adsscripts Training & Workshop