AssetGroupSelector
Contains the methods for filtering and sorting a list of asset groups. For information about selectors, see Selectors.
Example usage:
var iterator = AdsApp.assetGroups()
.withCondition("ClickConversionRate > 0.3")
.forDateRange("LAST_WEEK")
.orderBy("Clicks DESC")
.get();
while (iterator.hasNext()) {
var assetGroup = iterator.next();
var metrics = assetGroup.getStats();
}
Methods
Method Name | Return Type | Description |
---|---|---|
get | AssetGroupIterator | Gets an iterator used to iterate through the list of asset groups. |
orderBy(string orderBy) | AssetGroupSelector | Applies the specified ordering to the selected asset groups. |
withCondition(string condition) | AssetGroupSelector | Applies filter criteria to the asset groups. |
withIds(string[] ids) | AssetGroupSelector | Gets asset groups with the specified IDs. |
withLimit(int limit) | AssetGroupSelector | Gets the top n asset groups that match the selection criteria. |
get
Gets an iterator used to iterate through the list of asset groups.
Returns
Type | Description |
---|---|
AssetGroupIterator | An iterator used to iterate through the selected asset groups. |
orderBy(String orderBy)
Applies the specified ordering to the selected asset groups.
Specify the orderBy parameter in the form, "columnName orderDirection" where:
- columnName is one of the supported columns.
- orderDirection is the order to sort the results in. Set to ASC to order the results in ascending order or DESC to order the results in descending order. The default is ASC.
For example, the following call returns asset groups in ascending order by AverageCpc.
selector = selector.orderBy("AverageCpc");
Selectors support ordering entities by one field only. You may not order the list of entities by field x, and within x by field y, and so on. If you specify more than one orderBy()
call in a chain or in separate selector calls, Scripts orders the list of entities using the field specified in the last orderBy()
call.
Arguments
Name | Type | Description |
---|---|---|
orderBy | string | The ordering to apply. |
Returns
Type | Description |
---|---|
AssetGroupSelector | Selector with ordering applied. |
withCondition(String condition)
Applies filter criteria to the asset groups.
Specify the condition parameter in the form, "columnName operator value" where:
- columnName is one of the supported Columns.
- operator is one of the supported operators.
Operators
The operator that you use depends on the column's type. Operators are case-sensitive. For example, use STARTS_WITH instead of starts_with.
Operators for columns that contain integers and long values:
<
<=
>
>=
=
!=
Operators for columns that contain double values:
<
>
Operators for columns that contain string values:
=
!=
STARTS_WITH
STARTS_WITH_IGNORE_CASE
CONTAINS
CONTAINS_IGNORE_CASE
DOES_NOT_CONTAIN
DOES_NOT_CONTAIN_IGNORE_CASE
Operators for columns that contain enumeration values:
=
!=
IN []
NOT_IN []
Operators for columns that contain an array of strings:
CONTAINS_ALL
CONTAINS_ANY
CONTAINS_NONE
Supported Columns
Supported columns for asset group filtering. The names are case sensitive.
The following are the performance metrics columns you may specify.
Column | Type | Example |
---|---|---|
AbsoluteTopImpressionRate | double | withCondition("AbsoluteTopImpressionRate > 0.25") |
AverageCpc | double | withCondition("AverageCpc < 2.75") |
AverageCpm | double | withCondition("AverageCpm > 0.65") |
ClickConversionRate | double | withCondition("ClickConversionRate > 0.25") |
Clicks | long | withCondition("Clicks >= 33") |
ConvertedClicks | long | withCondition("ConvertedClicks >= 10") |
Cost | double | withCondition("Cost > 3.25") The cost is in the account's currency. |
Ctr | double | withCondition("Ctr > 0.05") The CTR is in the range 0..1, so use 0.05 for a 5% CTR. |
Impressions | long | withCondition("Impressions > 10") |
TopImpressionRate | double | withCondition("TopImpressionRate > 0.25") |
The following are the entity properties you may specify.
Column | Type | Example |
---|---|---|
Status | enumeration | The asset group's status. Possible case-sensitive values are:
withCondition("Status = ENABLED") |
Name | string | The asset group's name.withCondition("Name CONTAINS_IGNORE_CASE 'sport'") |
CampaignName | string | The campaign's name.withCondition("CampaignName CONTAINS_IGNORE_CASE 'truck'") |
KeywordMaxCpc | double | The asset group's CPC bid. The bid is in the account's currency.withCondition("KeywordMaxCpc > 5.0") |
CampaignStatus | enumeration | The campaign's status. Possible case-sensitive values are:
withCondition("CampaignStatus = PAUSED") |
LabelNames | string set | A list of one or more case-sensitive label names. Use to get asset groups associated with the named labels.withCondition("LabelNames CONTAINS_ANY ['bar', 'foo']") |
CampaignType | enumeration | The campaign's type. Possible case-sensitive values are:
withCondition("CampaignType = SHOPPING") |
Arguments
Name | Type | Description |
---|---|---|
condition | string | The condition to apply to the selector. |
Returns
Type | Description |
---|---|
AssetGroupSelector | Selector with the condition applied. |
withIds(string[] ids)
Gets asset groups with the specified IDs.
You may apply one or more conditions to a selector. A chain of conditions is considered an AND operation. For example, the entity is selected only if condition A is true AND condition B is true. For example, the following call selects only asset group 33333.
var selector = AdsApp.assetGroups()
.withIds(['11111', '22222', '33333'])
.withIds(['33333', '44444', '55555']);
Arguments
Name | Type | Description |
---|---|---|
ids | string[] | An array of asset group IDs. For limits, see Script execution limits. |
Returns
Type | Description |
---|---|
AssetGroupSelector | Selector with the IDs applied. |
withLimit(int limit)
Gets the top n asset groups that match the selection criteria.
Arguments
Name | Type | Description |
---|---|---|
limit | int | The number of asset groups to return. The actual number may be less. |
Returns
Type | Description |
---|---|
AssetGroupSelector | Selector with limit applied. |