Free Adwords Split Testing Script


Split Test Your Way To Wins

Any experienced marketer will tell you that constant split testing is the key to achieving ROI in your campaigns.

Sadly, many of those same marketers don’t practice what they preach.

I’ve used the below AdWords script long before the guys at Hanapin Marketing released a similar script over at the PPC Hero blog to help me stay on top of split testing my ads weekly and to also disable ads for poor performance.


The measuring of results within this script is based on the last 30 days of data, and on Conversions Rate ( since ads can have a huge impact on qualifying your leads ).

This script could easily be modified to pick the winning ad based on CTR or other metrics that are available within the AdWords script protocol.

Important things to know:

  • Only runs in adgroups with more than 1 active ad.
  • Makes changes only if ads have more then 100 clicks in last 30 days.
  • You can change the 100 clicks metric to impressions or conversions.
  • I wouldn’t suggest changing the date range from less than 30 days.

If you have low volume campaigns  or very poor performing ads within your adgroup, this script may never declare a winner as you may never accumulate 100 clicks within any 30 day window. If this happens to be the case with your campaigns, you may need to lower the amount of clicks needed or extend the date range.

This script is currently being used in AdWords campaigns for several clients in the lead generation space with a $3MM annual PPC budget, so it should work flawlessly out of the box for you.

Inside the AdWords interface, navigate to  ”Bulk Operations” -> “Create and manage scripts” and create a new script. Then copy and paste the below code into the form.

Be sure to set it to run “Weekly” so that you have more free time to focus on other aspects of your campaigns.

// Comma-separated list of recipients.

//This scipt list all the Ad Groups with only one Ad Text.
//A/B testing for Ads is essential to improve CTR
function main() {
var consoleText = "";
var numOfAdGroups = 0;
var justOneAdText = 0;

//Get All Enabled Campaigns
//It's just because to help list the AdGroups grouped by Campaign
//The list will be ordered by Impressions to see the most important Ad Groups first
var campaignIterator = AdWordsApp.campaigns()
//.withCondition("CampaignName CONTAINS_IGNORE_CASE 'XXXX'")
.orderBy("Impressions DESC")
.withCondition("Status = ENABLED")

while (campaignIterator.hasNext()){
var campaign =;

//Get All Enabled AdGroups within the Campaign
var adGroupIterator = AdWordsApp.adGroups()
.withCondition("CampaignName CONTAINS_IGNORE_CASE '" +
campaign.getName() + "'")
.withCondition("Status = ENABLED")

while (adGroupIterator.hasNext()){

var adgroup =;
var adTextNum = 0;
//Get All Enabled Ad Text within the Ad Group
var adIterator =
.orderBy("ConversionRate DESC")
.withCondition("AdGroupName CONTAINS_IGNORE_CASE '" +
adgroup.getName() + "'")
.withCondition("CampaignName CONTAINS_IGNORE_CASE '" +
campaign.getName() + "'")
.withCondition("Status = ENABLED")
.withCondition("Clicks > 19")
//.withCondition("Conversions >= 1")
.withCondition("Status = ENABLED")
.withCondition("Type = TEXT_AD")


while (adIterator.hasNext()) {
var ad =;

//Increase the adTextNum if a Text Ad found.


if(adTextNum > 1){

adgroup.getCampaign().getName() +
", " +
adgroup.getName() +
", has one or less active Ad Text. " + ad.getHeadline()




Logger.log('Ad Text report finished.');


Share This Post On Facebook Or Twitter Below. Thanks!

Hi! I'm Jason Brown and I’m a 36 year old digital marketing intrapreneur living in beautiful Louisville, Kentucky. I've been involved with the Internet since 1996 and have personally made millions online with my creative marketing tactics and persistence. I blog about marketing, money, and motivation. Thanks for stopping by!


  1. mike   •  

    What does this script do? Reading the code it looks like it goes into a campaign, gets all the enabled adgroups with > 100 clicks, and than what? Does it report back the winning ads? Does it pause the losers?

    Do you set your ads to rotate evenly in the campaign settings?

    • Jason Brown   •  

      Thanks Mike

      After going into the campaigns and finding enabled adgroups, it checks to see if the adgroup has 2 ads and if so, if they have more then 100 impressions ( over a 30 day time frame ). If the ads meet those requirements, it sorts the ads by highest Conversion Rate ( you can change this ) and then sets the lowest Conversion Rate ad to pause ( which you can also change to delete if you wanted ). It does not report back which ones it paused to you.

      I do set all of my ads to rotate evenly. AdWords has a nasty habit of selecting a “winning” ad too early in the rotation cycle if you let it optimize for you.

      I also have a script that lets you know when you only have 1 ad in an adgroup and report that information back to you so that you can always be split testing. Useful when you have lots of adgroups or forget to make a new ad after running the above script weekly.

      • mike   •  

        Really cool, thanks a lot! You should do another post sharing the script that checks for only 1 ad in a adgroup. Also any posts about campaign/adgroup/keyword structure and how to maximize quality score and ad rank would be helpful.

  2. Jamie Press   •  

    Cheers, Jason! Will implement this with a client tomorrow.

  3. Markus   •  

    Jason, looks like an aweosme script. I’m new to Adwords scripts; would it be possible to run the scrip on a campaign level?

    I have a few campaigns were I would like to test the script but don’t want to run it on every single campaign. Is this possible?

    • Jason Brown   •     Author


      Adwords scripts had the ability to only work within certain campaigns, adgroups, etc based on status, name, and lots of other variables.

      You would need to modify the script to only look within the campaigns named “***” as part of the script.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>