Executes the function specified by
functionName
on each
ManagedAccount
that the
AccountSelector
matches.
Executes the function specified by
functionName
on each
ManagedAccount
that the
AccountSelector
matches. Once all the accounts have been processed, the callback function, if specified by
optionalCallbackFunctionName
, is executed once. The input, if specified by
optionalInput
, will be passed into the function specified by
functionName
. For example,
accountSelector.executeInParallel(functionName, optionalCallbackFunctionName, optionalInput)The input can then be accessed in the function like this:
function functionName(optionalInput) { Logger.log(optionalInput); }
The function specified by functionName
can optionally return a string. For example,
return "Account name";
return "$100.22";
return "[email protected]";
return "5";
JSON.stringify(value)
can be used to convert a value to JSON and then return the string. For example,
return JSON.stringify({value:10, list:[1,2,3,4,5,6], name: "Joe Smith"});
These will be passed into the callback function in a list of ExecutionResult objects. If JSON.stringify(value)
is used in the callback function, the value can then be turned back into a JavaScript object with JSON.parse(returnValue)
. For example,
function optionalCallbackFunctionName(results) { for (var i = 0; i < results.length; i++) { object = JSON.parse(results[i].getReturnValue()); } }
executeInParallel
can operate simultaneously on up to 50 accounts. If the selector contains more than 50 accounts, an exception is thrown and no accounts are processed. You can limit the number of accounts for the executeInParallel
method using accountSelector.withLimit(accountLimit)
.
The signature for the optionalCallbackFunctionName
should be:
function callbackMethod(/*ExecutionResult[]*/ results) { }
Returns nothing.
Sets a custom date range onto the selector.
Sets a custom date range onto the selector. Both parameters can be either an object containing year, month, and day fields, or an 8-digit string in
YYYYMMDD
form. For instance,
March 24th, 2013
is represented as either
{year: 2013, month: 3, day: 24}
or
"20130324"
. The date range is inclusive on both ends, so
forDateRange("20130324", "20130324")
sets the range of one day.
Date range must be specified if the selector has conditions or ordering for a stat field. Note that only the last date range specified for the selector will take effect.
<aside class="warning">
Note that managed accounts only keep stats for the most recent 90 days. Statistics older than 90 days come back as
0
.
</aside>
Fetches the requested accounts and returns an iterator.
Returns the campaign to which this location belongs.
Returns the campaign to which this location belongs.
Returns the country code of this location.
Returns the country code of this location.
This is the standard two-letter country code, e.g. "US"
or "BR"
.
Returns the type of this entity as a
String
.
Returns the type of this entity as a
String
.
Returns the ID of the location.
Returns the ID of the location.
Location IDs are shared across campaigns. In order to uniquely identify a location exclusion, one must specify both its campaign ID and the location ID.
Returns the name of this location.
Returns the name of this location.
Returns stats for the specified custom date range.
Returns stats for the specified custom date range. Both parameters can be either an object containing year, month, and day fields, or an 8-digit string in
YYYYMMDD
form. For instance,
March 24th, 2013
is represented as either
{year: 2013, month: 3, day: 24}
or
"20130324"
. The date range is inclusive on both ends, so
forDateRange("20130324", "20130324")
defines a range of a single day.
Returns the target type of this location.
Returns the target type of this location.
The target type is a generic description of the location, such as "City"
, "Postal Code"
, or "Country"
. For a full list of target types, see the AdWords API documentation on geotargeting.
Returns the targeting status of this location.
Returns the targeting status of this location.
This can return one of three values:
"ACTIVE"
: indicates that the location can be targeted as normal. The vast majority of locations are active."PHASING_OUT"
: indicates that the location can be targeted, but that support will soon be removed. To get a list of which locations are phasing out, please see the AdWords API documentation on geotargeting."OBSOLETE"
: indicates that the location cannot be targeted.Specifies the ordering of the resulting entities.
Specifies the ordering of the resulting entities.
orderBy
parameter can have one of the following forms:
orderBy("Cost")
- orders results by Cost, in ascending order.orderBy("Ctr ASC")
- orders results by Ctr, in ascending order.orderBy("MaxCpc DESC")
- orders results by MaxCpc, in descending order.See withCondition(String) for enumeration of columns that can be used.
orderBy()
may be called multiple times. Consider the following example:
selector = selector.forDateRange("LAST_14_DAYS") .orderBy("Clicks DESC") .orderBy("CTR ASC");
The results will be ordered by Clicks in descending order. Results with equal Clicks value will be ordered by Ctr in ascending order.
If a stats column is used in the ordering, date range must be specified via forDateRange(String) or forDateRange(Object, Object).
LabelNames
column cannot be used for ordering.
Removes the location.
Removes the location.
Returns nothing.
Restricts this selector to return only customers with the given customer IDs.
Restricts this selector to return only customers with the given customer IDs.
var customerIds = ['123-456-7890', '234-567-8901', '345-678-9012']; selector = selector.withIds(customerIds);
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:
MccApp.accounts() .withIds(['123-456-7890', '234-567-8901', '345-678-9012']) .withIds(['345-678-9012', '456-789-0123', '567-890-1234']);will only get the customer with ID
345-678-9012
, since it would be the only customer that satisfies both ID conditions.The customer IDs can be passed in either as numbers, or as hyphen-separated strings. The following two calls do the same thing:
accounts.withIds(['123-456-7890', '234-567-8901', '345-678-9012']); accounts.withIds([1234567890, 2345678901, 3456789012]);
<aside class="warning">
Note that only single-customer (non-MCC) accounts can be selected by ID. To select all accounts under a submanager, instead specify a condition on
ManagerCustomerId
; e.g.
withCondition("ManagerCustomerId IN ['123-456-7890']")
</aside>
Specifies limit for the selector to use.
Specifies limit for the selector to use. For instance,
withLimit(50)
returns only the first 50 entities.
Fetches accounts (not including AdWords Express accounts). Supports filtering and sorting.
Typical usage: