AI-generated Key Takeaways
-
This object is used to fetch excluded audiences and supports filtering and sorting.
-
You can specify the ordering of the results using the
orderBy()method with various string formats. -
Conditions can be added to narrow down results using the
withCondition()method, which supports different operators and column types like ad group and campaign attributes. -
The number of entities returned can be limited using the
withLimit()method.
Typical usage:
var campaign = AdsApp.campaigns().get().next(); var excludedAudienceSelector = campaign.targeting().excludedAudiences(); var excludedAudienceIterator = excludedAudienceSelector.get(); while (excludedAudienceIterator.hasNext()) { var excludedAudience = excludedAudienceIterator.next(); }
Methods:
| Member | Type | Description |
|---|---|---|
| get() | AdsApp.SearchCampaignExcludedAudienceIterator |
Fetches the requested excluded audiences and returns an iterator. |
| orderBy(orderBy) | AdsApp.SearchCampaignExcludedAudienceSelector |
Specifies the ordering of the resulting entities. |
| withCondition(condition) | AdsApp.SearchCampaignExcludedAudienceSelector |
Adds the specified condition to the selector in order to narrow down the results. |
| withLimit(limit) | AdsApp.SearchCampaignExcludedAudienceSelector |
Specifies limit for the selector to use. |
get()
Fetches the requested excluded audiences and returns an iterator. Return values:
| Type | Description |
|---|---|
AdsApp.SearchCampaignExcludedAudienceIterator |
Iterator of the requested excluded audiences. |
orderBy(orderBy)
Specifies the ordering of the resulting entities. orderBy
parameter can have one of the following forms:
orderBy("campaign.name")- orders results by campaign.name, in ascending order.orderBy("campaign.name ASC")- orders results by campaign.name, in ascending order.orderBy("campaign.name DESC")- orders results by campaign.name, in descending order.
See SearchCampaignExcludedAudienceSelector.withCondition(String) for enumeration of columns that can be used.
orderBy() may be called multiple times. Consider the
following example:
selector = selector.
.orderBy("campaign.name")
.orderBy("ad_group.name");The results will be ordered by campaign.name in ascending order. Results with equal campaign.name value will be ordered by ad_group.name in ascending order.
Arguments:
| Name | Type | Description |
|---|---|---|
| orderBy | String |
Ordering to apply. |
Return values:
| Type | Description |
|---|---|
AdsApp.SearchCampaignExcludedAudienceSelector |
The 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("campaign.status = 'ENABLED'")
.withCondition("campaign.name REGEXP_MATCH 'a.*'");AND-ed together. The above
example will retrieve excluded audiences of type USER_LIST
from ENABLED Campaigns whose name starts with 'a'.
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
Stringcolumns (e.g. campaign.name):= != (NOT) (LIKE | CONTAINS | REGEXP_MATCH)
- For
Enumerationcolumns (ones that can only take one value from a pre-defined list, such as campaign.status):= != IN () NOT IN ()
IN, NOT IN, CONTAINS
ALL, CONTAINS ANY and CONTAINS NONE
operators look as follows:
withCondition("KeywordMatchType IN (Value1, Value2)")Columns
All column names are case-sensitive, and so are all values of enumerated columns (such as ad_group.status)
| Column | Type | Example |
|---|---|---|
| ad_group.name | String | withCondition("ad_group.name REGEXP_MATCH '.*shoes.*'") |
| ad_group.status |
Enumeration: ENABLED, PAUSED,
REMOVED
|
withCondition("ad_group.status = ENABLED"). Use to fetch
excluded audiences from only ENABLED ad groups.
|
| campaign.name | String | withCondition("campaign.name REGEXP_MATCH '.*promotion.*'") |
| campaign.status |
Enumeration: ENABLED, PAUSED,
REMOVED
|
withCondition("campaign.status = ENABLED"). Use to fetch
excluded audiences from only ENABLED campaigns.
|
Arguments:
| Name | Type | Description |
|---|---|---|
| condition | String |
Condition to add to the selector. |
Return values:
| Type | Description |
|---|---|
AdsApp.SearchCampaignExcludedAudienceSelector |
The selector with the condition applied. |
withLimit(limit)
Specifies limit for the selector to use. For instance,
withLimit(50) returns only the first 50 entities. Arguments:
| Name | Type | Description |
|---|---|---|
| limit | int |
How many entities to return. |
Return values:
| Type | Description |
|---|---|
AdsApp.SearchCampaignExcludedAudienceSelector |
The selector with limit applied. |