Contains the methods for filtering and sorting a list of ad group audiences. For information about selectors, see Selectors.
Example usage:
// Gets the iterator that iterates all ad group audiences
// in the account.
var iterator = AdsApp.adGroups().get();
// Loops through all ad groups in the account.
while (iterator.hasNext()) {
var adGroup = iterator.next();
// Gets the iterator that iterates all ad group audiences
// in the ad group audience.
var audienceIterator = adGroup.targeting().audiences()
.withLimit(10)
.withIds("123456789")
.get();
// Loops through all ad group audiences in the ad group audience.
while (audienceIterator.hasNext()) {
var audience = iterator.next();
}
}
Gets the top n ad group audiences that match the selection criteria.
forDateRange(Object dateFrom, Object dateTo)
Applies the start and end dates for selecting performance metrics.
Specify a date range only if:
You apply conditions or ordering that reference performance metric fields.
You want to get performance data for the objects you're selecting. For example, if you plan to call the getStats() method.
You may specify the date parameters using strings or objects. To use strings, specify the date in the form, YYYYMMDD. If you use objects, create an object with the following fields:
year
month
day
For example:
var date = {year: 2018, month: 5, day: 13};
The month is one-based where 1 is January and 12 is December.
The date range is inclusive. If you specify multiple date ranges, only the last date range is used.
Arguments
Name
Type
Description
dateFrom
Object
The start date of the date range that specifies the performance data to include in the selector. Specify the date using a string in the form, YYYYMMDD, or an object in the form, {year: 2020, month: 12, day: 31}.
dateTo
Object
The end date of the date range that specifies the performance data to include in the selector. Specify the date using a string in the form, YYYYMMDD, or an object in the form, {year: 2020, month: 12, day: 1}.
Applies the predefined date range for selecting performance metrics.
Specify a date range only if:
You apply conditions or ordering that reference performance metric fields.
You want to get performance data for the objects you're selecting. For example, if you plan to call the getStats() method.
If you specify multiple date ranges, only the last date range is used.
Supported date range values:
TODAY
YESTERDAY
LAST_WEEK
LAST_BUSINESS_WEEK
LAST_7_DAYS
THIS_WEEK_SUN_TODAY
LAST_14_DAYS
LAST_30_DAYS
LAST_WEEK_SUN_SAT
THIS_MONTH
LAST_MONTH
ALL_TIME
Arguments
Name
Type
Description
dateRange
String
The predefined date range string that specifies the performance data to include in the selector. The predefined date-range string is case sensitive. Possible case-sensitive values are: TODAY, YESTERDAY, LAST_WEEK, LAST_BUSINESS_WEEK, LAST_7_DAYS, THIS_WEEK_SUN_TODAY, LAST_14_DAYS, LAST_30_DAYS, LAST_WEEK_SUN_SAT, THIS_MONTH, LAST_MONTH, ALL_TIME.
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 ad group audiences 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.
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 ad group audience 33333.
var selector = AdsApp.adGroups()
.withIds(['11111', '22222', '33333'])
.withIds(['33333', '44444', '55555']);
Learn to control the size and order of query results in PostgreSQL with the LIMIT, OFFSET, and ORDER BY clauses. Master pagination, sorting, and optimizing performance with these essential SQL tools.