AI-generated Key Takeaways
-
Fetches negative keywords, excluding those from shared libraries, using the
negativeKeywords()
method of an ad group. -
Provides methods to iterate through, order, and filter negative keywords based on criteria like text, match type, or ad group/campaign status.
-
Uses a selector to define the criteria for fetching negative keywords, enabling flexible querying and retrieval.
-
Supports conditions using operators like
=
,!=
,LIKE
,CONTAINS
,REGEXP_MATCH
,IN
, andNOT IN
to refine the selection of negative keywords. -
Allows limiting the number of returned entities using
withLimit()
.
Typical usage:
var adGroup = AdsApp.adGroups().get().next(); var negativeKeywordSelector = adGroup.negativeKeywords(); var negativeKeywordIterator = negativeKeywordSelector.get(); while (negativeKeywordIterator.hasNext()) { var negativeKeyword = negativeKeywordIterator.next(); }
Methods:
Member | Type | Description |
---|---|---|
get() | AdsApp.NegativeKeywordIterator |
Fetches the requested negative keywords and returns an iterator. |
orderBy(orderBy) | AdsApp.NegativeKeywordSelector |
Specifies the ordering of the resulting entities. |
withCondition(condition) | AdsApp.NegativeKeywordSelector |
Adds the specified condition to the selector in order to narrow down the results. |
withLimit(limit) | AdsApp.NegativeKeywordSelector |
Specifies limit for the selector to use. |
get()
Fetches the requested negative keywords and returns an iterator. Return values:
Type | Description |
---|---|
AdsApp.NegativeKeywordIterator |
Iterator of the requested negative keywords. |
orderBy(orderBy)
Specifies the ordering of the resulting entities. orderBy
parameter can have one of the following forms:
orderBy("ad_group_criterion.keyword.text")
- orders results by text, in ascending order.orderBy("ad_group_criterion.keyword.text ASC")
- orders results by text, in ascending order.orderBy("ad_group_criterion.keyword.text DESC")
- orders results by text, in descending order.
See NegativeKeywordSelector.withCondition(String) for enumeration of columns that can be used.
orderBy()
may be called multiple times. Consider the
following example:
selector = selector. .orderBy("ad_group_criterion.keyword.text") .orderBy("ad_group_criterion.keyword.match_type");
The results will be ordered by text in ascending order. Results with equal text value will be ordered by match type in ascending order.
Arguments:
Name | Type | Description |
---|---|---|
orderBy | String |
Ordering to apply. |
Return values:
Type | Description |
---|---|
AdsApp.NegativeKeywordSelector |
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("ad_group_criterion.keyword.text REGEXP_MATCH 'a.*'") .withCondition("ad_group_criterion.keyword.match_type = BROAD");
AND
-ed together. The above
example will retrieve negative keywords that start with the letter 'a' and
are of broad match type.
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. ad_group_criterion.keyword.text):= != (NOT) (LIKE | CONTAINS | REGEXP_MATCH)
- For
Enumeration
columns (ones that can only take one value from a pre-defined list, such as ad_group_criterion.keyword.match_type):= != IN () NOT IN ()
IN
, NOT IN
, CONTAINS
ALL
, CONTAINS ANY
and CONTAINS NONE
operators look as follows:
withCondition("ad_group_criterion.keyword.match_type IN (Value1, Value2)")
Columns
All column names are case-sensitive, and so are all values of enumerated columns (such as KeywordMatchType)
Column | Type | Example |
---|---|---|
|
||
ad_group_criterion.keyword.text | String | withCondition("ad_group_criterion.keyword.text REGEXP_MATCH 'leather.*'") |
ad_group_criterion.keyword.match_type |
Enumeration: BROAD , EXACT ,
PHRASE
|
withCondition("ad_group_criterion.keyword.match_type = PHRASE") |
ad_group.name | String | withCondition("ad_group.name REGEXP_MATCH '.*shoes.*'") |
ad_group.status |
Enumeration: ENABLED , PAUSED ,
REMOVED
|
withCondition("ad_group.status = ENABLED") . Use to fetch
negative keywords from only ENABLED ad groups.
|
campaign.name | String | withCondition("campaign.name REGEXP_MATCH '.*promotion.*'") |
campaign.status |
Enumeration: ENABLED , PAUSED ,
REMOVED
|
withCondition("campaign.status = ENABLED") . Use to fetch
negative keywords from only ENABLED campaigns.
|
Arguments:
Name | Type | Description |
---|---|---|
condition | String |
Condition to add to the selector. |
Return values:
Type | Description |
---|---|
AdsApp.NegativeKeywordSelector |
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:
Name | Type | Description |
---|---|---|
limit | int |
How many entities to return. |
Return values:
Type | Description |
---|---|
AdsApp.NegativeKeywordSelector |
The selector with limit applied. |