AI-generated Key Takeaways
-
LanguageSelector fetches languages and supports filtering and sorting.
-
The
get()
method fetches the requested languages and returns an iterator. -
You can restrict the selection by language IDs using
withIds()
. -
The
withLimit()
method specifies the maximum number of entities to return. -
You can restrict the selection by Google Ads API resource names using
withResourceNames()
.
Typical usage:
var languageSelector = campaign.targeting() .languages() .withCondition("metrics.impressions > 100") .orderBy("metrics.clicks DESC"); var languageIterator = languageSelector.get(); while (languageIterator.hasNext()) { var language = languageIterator.next(); }
Methods:
Member | Type | Description |
---|---|---|
get() | AdsApp.LanguageIterator |
Fetches the requested languages and returns an iterator. |
withIds(ids) | AdsApp.LanguageSelector |
Restricts this selector to return only languages with the given language IDs. |
withLimit(limit) | AdsApp.LanguageSelector |
Specifies limit for the selector to use. |
withResourceNames(resourceNames) | AdsApp.LanguageSelector |
Restricts this selector to return only languages with the given Google Ads API resource names. |
get()
Fetches the requested languages and returns an iterator. Return values:
Type | Description |
---|---|
AdsApp.LanguageIterator |
Iterator of the requested languages. |
withIds(ids)
Restricts this selector to return only languages with the
given
language IDs.
All languages are uniquely identified by the combination of their ad group ID and language ID. The IDs for this selector are thus represented as two-element arrays, with the first element being the ad group ID and the second being the language ID:
var languageIds = [ ['12345', '987987'], ['23456', '876876'], ['34567', '765765'], ]; selector = selector.withIds(languageIds);
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:
var ids1 = [ ['12345', '987987'], ['23456', '876876'], ['34567', '765765'], ]; var ids2 = [ ['34567', '765765'], ['45678', '654654'], ['56789', '543543'], ]; AdsApp.targeting().languages() .withIds(ids1) .withIds(ids2);
['34567',
'765765']
, since it would be the only language that
satisfies both ID conditions. Arguments:
Name | Type | Description |
---|---|---|
ids | Object[][] |
Array of language IDs. |
Return values:
Type | Description |
---|---|
AdsApp.LanguageSelector |
The 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:
Name | Type | Description |
---|---|---|
limit | int |
How many entities to return. |
Return values:
Type | Description |
---|---|
AdsApp.LanguageSelector |
The selector with limit applied. |
withResourceNames(resourceNames)
Restricts this selector to return only languages with the
given Google Ads API resource names.
const languageResourceNames = [ 'customers/1234567890/campaignCriteria/111~222', 'customers/1234567890/campaignCriteria/111~333', 'customers/1234567890/campaignCriteria/444~555', ]; selector = selector.withResourceNames(languageResourceNames);
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:
Name | Type | Description |
---|---|---|
resourceNames | String[] |
Array of language resource names. |
Return values:
Type | Description |
---|---|
AdsApp.LanguageSelector |
The selector restricted to the given resource names. |