Rotating Ad Copy Script

You know how testing is one of the main things that makes PPC great? Well, this will turn your Google Ads account management into a well-oiled laboratory. The script labels the best and worst ads in the experiment, and shows you how much better your account would be doing if you paused all the losing ads accordingly. And then it actually pauses those ads (if you want it to)!

What’s included?

How does the script work?

The script goes through each ad group and finds the best ad. Then, it works out what could have happened if the other ads had been paused and all their impressions had gone to the winning ad. That tells you how much you’re missing out on (and which ad groups should be priorities when setting up new tests). It can automatically label ads as winners or losers, allowing you to easily check which ones are underperforming, and can also pause the losing ads, so you can be assured that you’re not wasting any more impressions.

To do this, the script assumes the same number of total impressions for the ad group, but with the average performance — CTR, CPC and so on — of the winning ad (or ads, if there’s a tie).

Obviously, these are just simple assumptions. Realistically, the performance would vary because those impressions may have been of different quality (and even the number of impressions could have been different, because this ad/keyword combination could have a higher Quality Score and be eligible for more searches). However, it’s enough to give you a rough estimate.

You get to choose which metric makes an ad a winner — CTR is an obvious choice, but if you have enough converting traffic, then you can use conversions per impression, or value per impression, or something entirely different.

Note that there’s no statistical significance checking in the script — it just checks against click and impression thresholds — so if there are ad groups where the performance is close, you may want to check for yourself whether the winner really is the winner.

Oh, and the script looks at mobile-preferred ads separately from all device ads. After all, the mobile-preferred ads should be picking up all of the mobile traffic. If we treated mobile ads like regular ones, it would be inaccurate, as mobile traffic tends to be very different from desktop and tablet traffic.

How do I use it?

Make a blank Google Sheet and take note of the URL. Then copy the script below, paste it into a new script in Google Ads and change a few settings at the top:

  1. spreadsheetUrl is the URL of a Google Doc spreadsheet, which the results will be written into.
    • Create a blank spreadsheet and put the URL in here.
  2. Set labelAds to true if you want winning and losing ads to be labeled, so you can find them easily in your account.
  3. labelTextForWinningAds is the text used to label the winning ads.
  4. labelTextForLosingAds is the text used to label the losing ads.
  5. Set pauseLosingAds to true if you want the script to automatically pause the losing ads.
  6. campaignNameContains and campaignNameDoesNotContain filter which campaigns the script gets data from. For example, if campaignNameContains is [“Brand,” “Generic”], then only campaigns with names containing “brand” or “generic” are included. If campaignNameDoesNotContain is [“Display,” “Competitor”], then any campaigns with names containing “display” or “competitor” are ignored.
  7. This is not case-sensitive.
  8. Leave blank, [], to include all campaigns.
  9. If you need to put a double quote into campaignNameContains or campaignNameDoesNotContain, put a backslash before it.
  10. ignorePausedCampaigns should be set to true if you only want to look at currently active campaigns, or false if you want to include paused ones.
  11. Similarly, ignorePausedAdGroups should be set to true if you only want to look at currently active ad groups or false if you want to include paused ones.
  12. conversionMetrics lists which conversion metrics will appear in the spreadsheet. You can have “Conversions,” “ConversionValue” or both.
  13. You have to pick which metric is used to determine the winning ad. Put that metric’s name in winningMetricName — This is used to name columns in the spreadsheet.
  14. The winning metric is calculated by dividing one metric (winningMetricMultiplier) by another (winningMetricDivisor). For example, if the winning metric is CTR, the winningMetricMultiplier is “Clicks,” and the winningMetricDivisor is “Impressions.”
  15. The script assumes the largest winning metric is the best. You want the highest CTR or the highest conversion per impression.
  16. impressionThreshold and clickThreshold are the minimum number of impressions and clicks on ads that need to be considered.
  17. The script will look at the performance of the ads over a time period specified by dateRange.
  18. You can use predefined date ranges like “LAST_30_DAYS,” “LAST_MONTH” or “THIS_MONTH.”
  19. Or you can make your own with the format “yyyymmdd, yyyymmdd” — the first date is the start and the second is the end. For example “20180101, 20180430” would cover January 1 to April 30, 2018.
  20. currencySymbol will be stuck in front of any currency values (i.e., costs and conversion values) in the spreadsheet.

If you’re having trouble with the script timing out, try running it multiple times using campaignNameContains and campaignNameDoesNotContain to look at different campaigns for each run. But the script will clear the Google Sheet when it runs, so make sure to use a different URL each time or save the data somewhere else.


  • Only enabled ads that aren’t disapproved are considered.
  • Ad groups where all ads are tied with the same winning metric are ignored. For example if all winning metric values are 0, the ad group will be ignored.
  • The totals shown will not be the same as your account’s totals. This only reports the performance of ad groups with winning and non-winning ads.
  • If the winningMetricMultiplier or winningMetricDivisor are not already one of the reported metrics, they will also be reported on. For example, if conversion metrics was “Conversions,” but the winningMetricMultiplier was “ConversionValue,” then both conversions and conversion value would be reported in the spreadsheet.

The Rotating Ad Copy script code