This simple but effective AdWords Script can be used to:

  1. Test different Ad Rotation settings
  2. Change Ad Rotation settings in bulk

free adwords script ad rotation types from google sheet

This script has been developed in order to allow scheduled tests of different Ad Rotation settings across multiple campaigns. It can also be used to simply change ad rotation settings, although a similar function is available in the AdWords Editor.

Simply add your experiment details and campaign names to the Google Sheet (make a copy), then either manually run the script or setup a schedule. A weekly or monthly schedule is recommended for cleaner, more accurate results.

Setup

  • Make a copy of the template Google Sheet
  • Enter the Ad Rotation variants in cells B2 and B3, choosing one of “OPTIMIZE”, “CONVERSION_OPTIMIZE”, “ROTATE”, or “ROTATE_FOREVER”.
  • List campaign names included in the experiment starting with cell A6
  • Setup a schedule or run as and when desired

To just change the setting, populate Variant A with your chosen setting, then run the script once.

AdWords Script Schedule Setup

The Script

/**
* AutomatingAdWords.com - Set or Test Campaign Ad Rotation Settings
*
* Go to automatingadwords.com for installation instructions and advice
*
* Version: 1
**/

//your spreadsheet URL
var SPREADSHEET_URL = "your-sheet-url";
//your sheet (tab) name
var SHEET_NAME = "Rotation Test";

var ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
var sheet = ss.getSheetByName(SHEET_NAME);
//Pull settings from sheet
var variantA = sheet.getRange(2,2).getValue();
var variantB = sheet.getRange(3,2).getValue();
function main() {//the game is afoot
  var currentVariant = "";
  var logRow = 7;
  var newVariant = "";
  if(sheet.getRange(logRow, 2).getValue()==""){
    currentVariant = "";
    newVariant = "A";
  }else{
    while(sheet.getRange(logRow, 2).getValue()){
      currentVariant = sheet.getRange(logRow, 2).getValue();
      logRow++;
    }
    if(currentVariant=="A"){newVariant="B"}else{newVariant="A"}
  }
  
  
  var changeLog = "";
  var changeDate = new Date();
  var row = 7;
  var sheetCampaigns = [];
  while(sheet.getRange(row, 1).getValue()){
   sheetCampaigns.push(sheet.getRange(row, 1).getValue());
    row++;
  }
  var campaigns = AdWordsApp.campaigns().get();
  while(campaigns.hasNext()){
   var campaign = campaigns.next();
   var campaignName = campaign.getName();
    if(sheetCampaigns.indexOf(campaignName)>0){
      
      if(newVariant=="A"){
      campaign.setAdRotationType(variantA);
      }else{
      campaign.setAdRotationType(variantB);  
      }
      sheet.getRange(logRow, 2).setValue(newVariant);
      sheet.getRange(logRow, 3).setValue(changeDate);
      
      
    }
    
  }
  
}

AdWords Experiments

Bear in mind Ad Rotation settings can be tested using AdWords experiments too, this may make more sense especially as it takes minutes:

  • Navigate to the campaign and click Drafts (located to the left of the date picker), then click Create New
  • Make the change to Ad Rotation settings (located in settings > Ad delivery: Ad rotation, frequency capping)
  • Save the draft, AdWords will then prompt asking if you would like to create an experiment- done!

What’s the difference?

An AdWords experiment should work just fine, but there are two key points to bear in mind.

This script allows testing in bulk. Experiments are easy to setup, but accounts with hundreds of campaigns aren’t uncommon. Plug thousands of campaigns into the sheet and it will work just fine.

When testing for conversions, a 50/50 at-auction A/B test (AdWords Experiments trigger at Auction) will mean only the AdWords conversion data will be available. When looking at different attribution models in Google Analytics or back office sales or CRM data, it might tell a different story – that’s what this allows.

Equally true A/B data will be more accurate, especially if other changes are being made in the account.

Like many things in AdWords, it boils down to circumstance, and remember both can always be setup.

Before You Go

Is this useful? Mind-numbingly useless? Either way, please comment.

Any feedback on how we can improve current scripts is welcome, as are ideas for new scripts.


Leave a Reply

Your email address will not be published. Required fields are marked *