AdsApp.​UserListSelector

Fetches user lists. Supports filtering and sorting.

Typical usage:

var userListSelector = AdsApp.userlists()
    .withCondition("metrics.impressions > 100")
    .orderBy("metrics.clicks DESC");

var userListIterator = userListSelector.get();
while (userListIterator.hasNext()) {
  var userList = userListIterator.next();
}
Related:

Methods:

MemberTypeDescription
getAdsApp.UserListIteratorFetches the requested user lists and returns an iterator.
orderByAdsApp.UserListSelectorSpecifies the ordering of the resulting entities.
withConditionAdsApp.UserListSelectorAdds the specified condition to the selector in order to narrow down the results.
withIdsAdsApp.UserListSelectorRestricts this selector to return only user lists with the given user list IDs.
withLimitAdsApp.UserListSelectorSpecifies limit for the selector to use.
withResourceNamesAdsApp.UserListSelectorRestricts this selector to return only user lists with the given Google Ads API resource names.

get()

Fetches the requested user lists and returns an iterator.

Return values:

TypeDescription
AdsApp.UserListIteratorIterator of the requested user lists.

orderBy(orderBy)

Specifies the ordering of the resulting entities. orderBy parameter can have one of the following forms:
  • orderBy("user_list.membership_life_span") - orders results by user_list.membership_life_span, in ascending order.
  • orderBy("user_list.size_for_search ASC") - orders results by user_list.size_for_search, in ascending order.
  • orderBy("user_list.name DESC") - orders results by user_list.name, in descending order.

See UserListSelector.withCondition(String) for enumeration of columns that can be used.

orderBy() may be called multiple times. Consider the following example:

selector = selector.orderBy("user_list.name ASC")
    .orderBy("user_list.membership_life_span DESC");

The results will be ordered by user_list.name in ascending order. Results with equal user_list.name values will be ordered by user_list.membership_life_span in descending order.

Arguments:

NameTypeDescription
orderByStringOrdering to apply.

Return values:

TypeDescription
AdsApp.UserListSelectorThe selector with ordering applied.

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("user_list.membership_life_span > 30")
                   .withCondition("user_list.size_for_search > 1000");
All specified conditions are AND-ed together. The above example will retrieve entities with a membership life span of more than 30 days and 100 members eligible for search campaigns/ad groups.

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 Integer and Long columns (e.g. user_list.size_for_search):
    <  <=  >  >= =  !=
  • For String columns (e.g. user_list.name):
    =  !=  (NOT) (LIKE | CONTAINS | REGEXP_MATCH)
  • For Enumeration columns (ones that can only take one value from a predefined list, such as user_list.status):
    =  !=  IN () NOT IN ()
Conditions using IN, NOT IN, CONTAINS ALL, CONTAINS ANY and CONTAINS NONE operators look as follows:
withCondition("ColumnName IN (Value1, Value2)")

Columns

All column names are case-sensitive, and so are all values of enumerated columns (such as Status).

ColumnTypeExample
User list attributes
user_list.idLongwithCondition("user_list.id = 123456789").
user_list.nameStringwithCondition("user_list.name REGEXP_MATCH '.*visitor.*'")
user_list.descriptionStringwithCondition("user_list.description = 'Description of a user list'")
user_list.typeEnumeration: UNKNOWN, REMARKETING, LOGICAL, EXTERNAL_REMARKETING, RULE_BASED, SIMILAR, CRM_BASEDwithCondition("user_list.type = CRM_BASED")
user_list.membership_statusEnumeration: UNKNOWN, OPEN, CLOSEDwithCondition("user_list.membership_status = OPEN")
user_list.membership_life_spanLongwithCondition("user_list.membership_life_span > 30")
user_list.size_for_displayLongwithCondition("user_list.size_for_display < 5000")
user_list.size_for_searchLongwithCondition("user_list.size_for_search < 5000")
user_list.size_range_for_displayEnumeration: LESS_THAN_FIVE_HUNDRED, LESS_THAN_ONE_THOUSAND, ONE_THOUSAND_TO_TEN_THOUSAND, TEN_THOUSAND_TO_FIFTY_THOUSAND, FIFTY_THOUSAND_TO_ONE_HUNDRED_THOUSAND, ONE_HUNDRED_THOUSAND_TO_THREE_HUNDRED_THOUSAND, THREE_HUNDRED_THOUSAND_TO_FIVE_HUNDRED_THOUSAND, FIVE_HUNDRED_THOUSAND_TO_ONE_MILLION, ONE_MILLION_TO_TWO_MILLION, TWO_MILLION_TO_THREE_MILLION, THREE_MILLION_TO_FIVE_MILLION, FIVE_MILLION_TO_TEN_MILLION, TEN_MILLION_TO_TWENTY_MILLION, TWENTY_MILLION_TO_THIRTY_MILLION, THIRTY_MILLION_TO_FIFTY_MILLION, OVER_FIFTY_MILLIONwithCondition("user_list.size_range_for_display = FIFTY_THOUSAND_TO_ONE_HUNDRED_THOUSAND")
user_list.size_range_for_searchEnumeration: LESS_THAN_FIVE_HUNDRED, LESS_THAN_ONE_THOUSAND, ONE_THOUSAND_TO_TEN_THOUSAND, TEN_THOUSAND_TO_FIFTY_THOUSAND, FIFTY_THOUSAND_TO_ONE_HUNDRED_THOUSAND, ONE_HUNDRED_THOUSAND_TO_THREE_HUNDRED_THOUSAND, THREE_HUNDRED_THOUSAND_TO_FIVE_HUNDRED_THOUSAND, FIVE_HUNDRED_THOUSAND_TO_ONE_MILLION, ONE_MILLION_TO_TWO_MILLION, TWO_MILLION_TO_THREE_MILLION, THREE_MILLION_TO_FIVE_MILLION, FIVE_MILLION_TO_TEN_MILLION, TEN_MILLION_TO_TWENTY_MILLION, TWENTY_MILLION_TO_THIRTY_MILLION, THIRTY_MILLION_TO_FIFTY_MILLION, OVER_FIFTY_MILLIONwithCondition("user_list.size_range_for_search = FIFTY_THOUSAND_TO_ONE_HUNDRED_THOUSAND")
user_list.eligible_for_displayBooleanwithCondition("user_list.eligible_for_display = true")
user_list.eligible_for_searchBooleanwithCondition("user_list.eligible_for_search = true")

Arguments:

NameTypeDescription
conditionStringCondition to add to the selector.

Return values:

TypeDescription
AdsApp.UserListSelectorThe selector with the condition applied.

withIds(ids)

Restricts this selector to return only user lists with the given user list IDs.
var userListIds = ['12345', '23456', '34567'];
selector = selector.withIds(userListIds);

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:

AdsApp.userLists().userLists()
   .withIds(['12345', '23456', '34567'])
   .withIds(['34567', '45678', '56789']);
will only get the user list with ID 34567, since it would be the only user list 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
idsObject[]Array of user list IDs.

Return values:

TypeDescription
AdsApp.UserListSelectorThe selector restricted to the given IDs.

withLimit(limit)

Specifies limit for the selector to use. For instance, withLimit(50) returns only the first 50 entities.

Arguments:

NameTypeDescription
limitintHow many entities to return.

Return values:

TypeDescription
AdsApp.UserListSelectorThe selector with limit applied.

withResourceNames(resourceNames)

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

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
resourceNamesString[]Array of user list resource names.

Return values:

TypeDescription
AdsApp.UserListSelectorThe selector restricted to the given resource names.