• Search Engine Land
  • Sections
    • SEO
    • SEM
    • Mobile
    • Local
    • Retail
    • Google
    • Bing
    • Social
    • Home
  • Follow Us
    • Follow
  • Search Engine Land
  • SEO
  • SEM
  • Mobile
  • Local
  • Retail
  • Google
  • Bing
  • Social
  • More
  • Events
    • Follow
  • SUBSCRIBE

Search Engine Land

Search Engine Land

Events

Join us at SMX Advanced!

  • SEO
  • SEM
  • Mobile
  • Local
  • Retail
  • Google
  • Bing
  • Social
  • Newsletters
  • Home
SEM

Sign up for our daily recaps of the ever-changing search marketing landscape.

Note: By submitting this form, you agree to Third Door Media's terms. We respect your privacy.


Here’s An AdWords Script That Will Let You A/B Test Anything

Columnist Daniel Gilbert wasn't satisfied with AdWords' native A/B testing capabilities, so he and his team wrote a script.

Daniel Gilbert on February 11, 2015 at 9:50 am
  • More
split testing

Any paid search manager will know that A/B testing is a critical part of AdWords success. Few other marketing channels offer such rich data on performance and allow for tweaks as wide-ranging as changing keywords to changing bids every hour of the day.

Yet for some reason, Google’s native testing platform, AdWords Campaign Experiments, is totally deficient. Aside from being clunky and difficult to use, there is the inherent problem that you must set up an experiment as a campaign setting, and therefore cannot test any campaign settings themselves.

At Brainlabs (my employer), we pride ourselves on scientific testing and needed a way around this. As every statistician knows, before/after analysis is weak. That is particularly true for AdWords, which is an auction where everything changes in a minute, let alone two weeks or a month. So we built an AdWords script which we’re sharing below to tackle this problem.

The logic behind the script is actually quite simple. You take a campaign and duplicate it twice. You label each one (I’d suggest “control” and “experiment”), add those labels to the script, and then run it on an hourly schedule.

The script works by alternating the campaigns on hourly schedules, so one goes on and the other goes off. They alternate all day for a few weeks until you’ve built up roughly even impressions on each. From there, you can visit the Dimensions tab, view Campaign Labels, and there you’ll have rich A/B data on your campaign performance.

Capture

[CLICK TO ENLARGE]

The caveat here is that the logic is not perfect on this script because it can only run every hour. If you’re feeling adventurous, then it’s possible to do this via the AdWords API and run more regular switching.

You’ll also notice that Google rarely serves each campaign evenly, which is partly down to Quality Score and partly down to chance.

/**
*
* Brainlabs A/B Testing Tool
*
* This script will pause and activate campaigns every hour.

*
* Version: 1.0
* AdWords script maintained on brainlabsdigital.com
*
**/

function main() {

var labelA = "Control";
var labelB = "Experiment";

var days = [31,28,31,30,31,30,31,31,30,31,30,31];

var date = new Date();
var timeZone = AdWordsApp.currentAccount().getTimeZone();
var month = parseInt(Utilities.formatDate(date, timeZone, "MM"), 10) - 1;
var dayOfMonth = parseInt(Utilities.formatDate(date, timeZone, "dd"), 10);
var hour = parseInt(Utilities.formatDate(date, timeZone, "HH"), 10);

var totalDays = 0;

for(var i = 0; i < month; i++){
totalDays += days[i];
}

totalDays += dayOfMonth;

Logger.log("Day of year: " + totalDays);

Logger.log("hour: " + hour);

if(totalDays % 2 === 0){
if(hour % 2 === 0){
EnableCampaigns(labelA)
PauseCampaigns(labelB)
}
else{
EnableCampaigns(labelB)
PauseCampaigns(labelA)
}
}
else{
if(hour % 2 === 0){
EnableCampaigns(labelB)
PauseCampaigns(labelA)
}
else{
EnableCampaigns(labelA)
PauseCampaigns(labelB)
}
}
}

function PauseCampaigns(label){
var campaignIterator = AdWordsApp.campaigns()
.withCondition("LabelNames CONTAINS_ANY ['" + label + "']")
.get();
while(campaignIterator.hasNext()){
var campaign = campaignIterator.next();
campaign.pause();
}
}

function EnableCampaigns(label){
var campaignIterator = AdWordsApp.campaigns()
.withCondition("LabelNames CONTAINS_ANY ['" + label + "']")
.get();
while(campaignIterator.hasNext()){
var campaign = campaignIterator.next();
campaign.enable();
}
}

Opinions expressed in this article are those of the guest author and not necessarily Search Engine Land. Staff authors are listed here.



About The Author

Daniel Gilbert
Daniel Gilbert is the CEO at Brainlabs, the best paid media agency in the world (self-declared). He has started and invested in a number of big data and technology startups since leaving Google in 2010.

Popular Stories

AMP Stories: The new Accelerated Mobile Pages format from Google
Let's face it - clickbait works. Here's how to use it to your advantage
Google Trends Showing A Swastika (卐)?
How To Localize Google Search Results

Related Topics

Channel: SEMGoogleGoogle: AdWordsGoogle: AdWords: AdWords ScriptsPaid Search Column

Sign up for our daily recaps of the ever-changing search marketing landscape.

Note: By submitting this form, you agree to Third Door Media's terms. We respect your privacy.


We're listening.

Have something to say about this article? Share it with us on Facebook, Twitter or our LinkedIn Group.

Attend Our Conferences

April 2-3, 2019: SMX Munich

May 21-22, 2019: SMX London

June 3-5, 2019: SMX Advanced

June 12-13, 2019: SMX Paris

Sept 30 - Oct 1, 2019: SMX Advanced Europe

November 13-14, 2019: SMX East

×

Attend SMX - Click Here


Learn More About Our SMX Events

Gain new strategies and insights at the intersection of marketing, technology, and management. Our next conference will be held:

April 3-5, 2019: San Jose

September 16-18, 2019: Boston

×

Attend MarTech - Click Here


Learn More About Our MarTech Events

White Papers

  • The Ultimate Guide to Site Search User Experience
  • The Marketing Analytics Buyer’s Guide 2019
  • Mission Possible: Quality Content Marketing
  • 2019 Marketing Trends: Nine factors reshaping marketing and how you can stay ahead of them
  • The Dummies Guide to Enterprise Customer Data Platforms
See More Whitepapers

Webinars

  • How to Use Intelligent Site Search to Increase Conversions
  • Google’s Black Box Bidding Solution: A look under the hood
  • 2019 Martech Trends You Need To Know
See More Webinars

Research Reports

  • B2B Marketing Automation Platforms
  • Account-Based Marketing Tools
  • Enterprise SEO Platforms
  • Call Analytics Platforms
  • Paid Media Campaign Management Platforms
  • Local Marketing Automation Tools
See More Research
Sign up for our daily newsletter.
Search Engine Land
Download the Search Engine Land app on iTunes Download the Search Engine Land App on Google Play

Follow Us

© 2019 Third Door Media, Inc. All rights reserved.