What does it do?
In this simple form the script attempts to replicate the "rotate evenly" setting available in regular Campaigns. Given any number of Ads in the Group, when the script runs it pauses any currently enable Ad then enables the one with the least number of impressions "today". Run once an hour, this should effectively rotate all your Shopping Ads throughout the day allowing you to examine their performance over a reasonable period of time.
Since the Ad chosen to be enabled is always the one with the least impressions, in theory the Ads should rotate in such a way that the same Ad isn't always shown at the same hour of the day, making the test a little more "even", though you could always experiment with programming in another randomising factor.
How do I choose the best Ad?
Once (if) you see a clear "winner" you can either simply remove the script schedule and ensure that winner is enabled, or you can remove the other Ads, it's up to you.
The code
Copy and paste the code below into a new Script, give it an appropriate name, authorise it then PREVIEW the script to check it works as expected.
Note that as provided, the Script will operate on all Shopping Campaigns in the Account. If you wish to limit which Campaigns it operates upon, you can enable either the name choice condition or the Label choice condition (by removing the // at the start of these lines). Note also that the script expects there to be at least two Ads in each Campaign.
Ideally I'd suggest scheduling the script to run every hour but you could also try just once a day or even once a week. Experiment!
As always, the script is provided with no guarantees and you should preview and test it thoroughly before use.
UPDATE: The code below now checks for multiple Ad Groups and uses only those enabled.
UPDATE: Now always rotates to a new Ad, regardless of impressions count of Ad currently showing.
// Shopping Ad Rotation Script (c) Jon Gritton 2015
function main() {var sCamp = AdWordsApp.shoppingCampaigns()
// optional conditions to pick specific Campaigns
//.withCondition("Name CONTAINS 'XXX'") // use to pick by name
//.withCondition("LabelNames CONTAINS_ANY ['ShopAdTest']") // use to pick by Label
.withCondition("Status = 'ENABLED'")
.get();
while (sCamp.hasNext()) {
var thisCamp = sCamp.next();
Logger.log(thisCamp.getName());
var pAdGs = thisCamp.adGroups()
.withCondition("Status = 'ENABLED'")
.get();
while (pAdGs.hasNext()) {
var thisAdG = pAdGs.next();
var pAds = thisAdG.ads()
.withCondition("Status = 'ENABLED'")
.get();
while(pAds.hasNext()) {
var currAd = pAds.next();
}
var eAd = thisAdG.ads()
.withCondition("Status = 'PAUSED'")
.orderBy("Impressions ASC")
.forDateRange("TODAY")
.withLimit(1)
.get().next();
eAd.enable();
currAd.pause();
Logger.log("Enabled: " + eAd.getId() + ", Paused: " + currAd.getId());
}
}
}