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.

Chat with SearchBot

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 

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
Contributor
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.

Get the must-read newsletter for search marketers.