This is the legacy documentation for Google Ads scripts. Go to the current docs.

AdsApp.​SearchCampaignExcludedAudienceSelector

Fetches excluded audiences. Supports filtering and sorting.

Typical usage:

 var campaign = AdsApp.campaigns().get().next();
 var excludedAudienceSelector = campaign.targeting().excludedAudiences();

 var excludedAudienceIterator = excludedAudienceSelector.get();
 while (excludedAudienceIterator.hasNext()) {
   var excludedAudience = excludedAudienceIterator.next();
 }
Related:

Methods:

MemberTypeDescription
get AdsApp.SearchCampaignExcludedAudienceIterator Fetches the requested excluded audiences and returns an iterator.
orderBy AdsApp.SearchCampaignExcludedAudienceSelector Specifies the ordering of the resulting entities.
withCondition AdsApp.SearchCampaignExcludedAudienceSelector Adds the specified condition to the selector in order to narrow down the results.
withLimit AdsApp.SearchCampaignExcludedAudienceSelector Specifies limit for the selector to use.

get()

Fetches the requested excluded audiences and returns an iterator.

Return values:

TypeDescription
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("CampaignName") - orders results by CampaignName, in ascending order.
  • orderBy("CampaignName ASC") - orders results by CampaignName, in ascending order.
  • orderBy("CampaignName DESC") - orders results by CampaignName, 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("CampaignName")
     .orderBy("AdGroupName");

The results will be ordered by CampaignName in ascending order. Results with equal CampaignName value will be ordered by AdGroupName in ascending order.

Arguments:

NameTypeDescription
orderBy String Ordering to apply.

Return values:

TypeDescription
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("CampaignStatus = 'ENABLED'")
     .withCondition("CampaignName STARTS_WITH 'a'");
All specified conditions are 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 String columns (e.g. CampaignName):
    =  !=  STARTS_WITH  STARTS_WITH_IGNORE_CASE  CONTAINS
     CONTAINS_IGNORE_CASE  DOES_NOT_CONTAIN  DOES_NOT_CONTAIN_IGNORE_CASE
  • For Enumeration columns (ones that can only take one value from a pre-defined list, such as CampaignStatus):
    =  !=  IN []  NOT_IN []
Conditions using IN, NOT_IN, CONTAINS_ALL, CONTAINS_ANY and CONTAINS_NONE operators look as follows:
 withCondition("KeywordMatchType IN [Value1, Value2]")
Operators are case-sensitive: starts_with won't work.

Columns

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

Column Type Example
Excluded audience attributes
AdGroupName String withCondition("AdGroupName CONTAINS_IGNORE_CASE 'shoes'")
AdGroupStatus Enumeration: ENABLED, PAUSED, REMOVED withCondition("AdGroupStatus = ENABLED"). Use to fetch excluded audiences from only ENABLED ad groups.
CampaignName String withCondition("CampaignName CONTAINS_IGNORE_CASE 'promotion'")
CampaignStatus Enumeration: ENABLED, PAUSED, REMOVED withCondition("CampaignStatus = ENABLED"). Use to fetch excluded audiences from only ENABLED campaigns.

Arguments:

NameTypeDescription
condition String Condition to add to the selector.

Return values:

TypeDescription
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:

NameTypeDescription
limit int How many entities to return.

Return values:

TypeDescription
AdsApp.SearchCampaignExcludedAudienceSelector The selector with limit applied.