AdWords
2.1K members online now
2.1K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me
star_border
Reply

Update Shopping Campaign Subdivision via Scripts

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi, my problem is similar to this unanswered thread over in the Google Product Forums, but let me explain it a little bit.

 

Currently I click through my shopping campaigns (quite a lot - one for every brand) and manually check for products which are currently not a child of my brand productgroup (which is subdivided by article-id) and have to be added (screenshot below)

 

manual.PNG  manual2.PNG

 

 

 

In the long term I would like to run through all (or as many as possible due to script runtime limitations) my Shopping Campaigns and have this done by a script.

 

I already started scripting but I can't find anything (wether documentation, examples or forums) related to getting a list of all products available in AdWords.

In other words this as an accessible list in AdWords Scripts :

 

manual3.PNG

 

If I had this list I could iterate through it, comparing the brand-attributes. Every match could then be checked if already existent as own product group, and if not added.

 

Code as of now:

Spoiler
function main() {
  var all = AdWordsApp.shoppingCampaigns()
  .withCondition("CampaignName != 'SC_CatchAll' AND CampaignName STARTS_WITH 'SC_'")
  .get();
  var i = 0;
  while (all.hasNext() && i < 1) {
    var campaign = all.next();
    campaign.
    Logger.log('Campaign Name: %s', campaign.getName());
    Logger.log(num_current(campaign) + ' products');
    i++;
  }
}

function num_current(campaign) {
  var all_groups = campaign.productGroups().get();
  while (all_groups.hasNext()) {
    var group = all_groups.next();
    var children = group.children().get();
    var ii = 0;
    while (children.hasNext()) {
      var child = children.next();
      if (child.getValue().search(/\d/) == 0) {
        ii++;
      }
    } 
    if (ii != 0) {
      var updated = update(group);
      return updated + ': had '+ ii;
    }
  }
}

function update(group) {
  var name = group.getValue();
  var matched_list = match(name);
  //do the following for each matched article-id
  Logger.log('Errors: ' + group.newChild().itemIdBuilder().withValue('160469761').build().getErrors());
  return 'Productgroup ' + name;
}

function match(brand) {
  //var product_list = ...?
  //...
}

 

Thank you in advance for every help provided.

 

 

1 Expert replyverified_user

Re: Update Shopping Campaign Subdivision via Scripts

Community Manager
# 2
Community Manager
Hi Janik,

Thanks for posting. The AdWords Scripts Forum is still going to be the best place for you to get an answer to this question, since this community deals primarily with questions that fall within the AdWords or AdWords Editor interfaces.

Sorry we couldn't provide a better answer here,
Cassie