Monday 30 March 2015

Shopping Promo Rotation

As we all know, Shopping Campaign Ads can - and should! - contain a short promotional text line to enhance their appeal.  You can read up on it here.  Promotional text can have a big impact on the performance of your Shopping Ads but how do you test different versions?  Although Shopping Ad Groups allow you to create more than one Ad (and therefore more than one version of the promo text) there's currently no option to rotate these Ads or optimise them for conversions or clicks.  I recently wanted to test various texts and came up with this solution, using Scripts, of course.

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'")
  while (sCamp.hasNext()) {
    var thisCamp =;
    var pAdGs = thisCamp.adGroups()
      .withCondition("Status = 'ENABLED'")
    while (pAdGs.hasNext()) {
      var thisAdG =;
      var pAds =
        .withCondition("Status = 'ENABLED'")
      while(pAds.hasNext()) {
        var currAd =;
      var eAd =
      .withCondition("Status = 'PAUSED'")
      .orderBy("Impressions ASC")
      Logger.log("Enabled: " + eAd.getId() + ", Paused: " + currAd.getId());