AdsManagerApp.​AccountLabelSelector

Fetches account labels. Supports filtering.

Typical usage:

var accountLabelSelector = AdsManagerApp.accountLabels()
    .withCondition("Name CONTAINS 'priority'");

var accountLabelIterator = accountLabelSelector.get();
while (accountLabelIterator.hasNext()) {
  var accountLabel = accountLabelIterator.next();
}
Related:

Methods:

MemberTypeDescription
get AdsManagerApp.AccountLabelIterator Fetches the requested account labels and returns an iterator.
withCondition AdsManagerApp.AccountLabelSelector Adds the specified condition to the selector in order to narrow down the results.
withIds AdsManagerApp.AccountLabelSelector Restricts this selector to return only account labels with the given account label IDs.
withResourceNames AdsManagerApp.AccountLabelSelector Restricts this selector to return only account labels with the given Google Ads API resource names.

get()

Fetches the requested account labels and returns an iterator.

Return values:

TypeDescription
AdsManagerApp.AccountLabelIterator Iterator of the requested account labels.

withCondition(condition)

Adds the specified condition to the selector in order to narrow down the results.

Multiple conditions may be added to the same selector:

selector = selector
    .withCondition("Name CONTAINS 'PRIORITY'")
    .withCondition("Name DOES_NOT_CONTAIN 'FINISHED'");
All specified conditions are AND-ed together. The above example will retrieve labels whose name contains PRIORITY but doesn't contain FINISHED.

The parameter to be passed into this method must be of the following form:

"COLUMN_NAME OPERATOR VALUE"

Operators

The operator that can be used in a condition depends on the type of column.
  • For String columns (e.g. Name):
    =  !=  STARTS_WITH  STARTS_WITH_IGNORE_CASE
    CONTAINS  CONTAINS_IGNORE_CASE  DOES_NOT_CONTAIN
    DOES_NOT_CONTAIN_IGNORE_CASE
Operators are case-sensitive: starts_with won't work.

Columns

All column names are case-sensitive.

Column Type Example
Name String withCondition("Name CONTAINS 'priority'")

Arguments:

NameTypeDescription
condition String Condition to add to the selector.

Return values:

TypeDescription
AdsManagerApp.AccountLabelSelector The selector with the condition applied.

withIds(ids)

Restricts this selector to return only account labels with the given account label IDs.
var accountLabelIds = ['12345', '23456', '34567'];
selector = selector.withIds(accountLabelIds);

The resulting selector can be further refined by applying additional conditions to it. The ID-based condition will then be AND-ed together with all the other conditions, including any other ID-based conditions. So, for instance, the following selector:

AdsManagerApp.accountLabels()
   .withIds(['12345', '23456', '34567'])
   .withIds(['34567', '45678', '56789']);
will only get the account label with ID 34567, since it would be the only account label that satisfies both ID conditions.

The selector can only support up to 10,000 IDs. If more than 10,000 IDs are specified, the corresponding get() call will fail with a runtime error.

Arguments:

NameTypeDescription
ids Object[] Array of account label IDs.

Return values:

TypeDescription
AdsManagerApp.AccountLabelSelector The selector restricted to the given IDs.

withResourceNames(resourceNames)

Restricts this selector to return only account labels with the given Google Ads API resource names.
const accountLabelResourceNames = [
  'customers/1234567890/labels/111',
  'customers/1234567890/labels/222',
  'customers/1234567890/labels/333',
];
selector = selector.withResourceNames(accountLabelResourceNames);

The resulting selector can be further refined by applying additional conditions to it. The resource name condition will then be AND-ed together with all the other conditions.

The selector can only support up to 10,000 resource names. If more than 10,000 resource names are specified, the corresponding get() call will fail with a runtime error.

Arguments:

NameTypeDescription
resourceNames String[] Array of account label resource names.

Return values:

TypeDescription
AdsManagerApp.AccountLabelSelector The selector restricted to the given resource names.