Pregunta

We have many accounts we manage and the ones we are interested have the label 'Active Clients'. This label is shown on the first page of the MCC ('My Client Center') in the table. It is the second column of the table that shows 'Labels'.

Here's the basic script:

function main() {

  var accountSelector = MccApp.accounts()
  .withCondition("Labels = 'Active Clients'");

  var accountIterator = accountSelector.get();

  // Iterate through the list of accounts
  while (accountIterator.hasNext()) {
  var account = accountIterator.next();

  // Select the client account.
  MccApp.select(account);

  // Operate on client account
  Logger.log('Customer ID: ' + account.getCustomerId() );
  }

}

This is how I'm trying to iterate through all clients that have the label 'Active Clients'. It doesn't work and I'm wondering if it can be made to work or I must specify the id's of all clients.

¿Fue útil?

Solución

The column name is LabelNames instead of Labels. Also its type is StringSet, not String, so you should use .withCondition("LabelNames CONTAINS_ANY ['Active Clients']"). However, "LabelNames" is not an available column for AccountSelector conditions yet (https://developers.google.com/adwords/scripts/docs/reference/mccapp/mccapp_accountselector#withCondition_1), hope this will change by time.

Anyway, I recommend to create a new MCC, where you keep only active clients, so you can place the script there without using withCondition.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top