AdsApp.NegativeKeywordSelector
Stay organized with collections
Save and categorize content based on your preferences.
Fetches negative keywords (except from shared libraries).
Typical usage:
var adGroup = AdsApp.adGroups().get().next();
var negativeKeywordSelector = adGroup.negativeKeywords();
var negativeKeywordIterator = negativeKeywordSelector.get();
while (negativeKeywordIterator.hasNext()) {
var negativeKeyword = negativeKeywordIterator.next();
}
Related:
Methods:
get()
Fetches the requested negative keywords and returns an iterator.
Return values:
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:
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");
All specified conditions are
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 ()
Conditions using
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 |
Negative keyword attributes
|
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:
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:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-25 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eFetches negative keywords, excluding those from shared libraries, using the \u003ccode\u003enegativeKeywords()\u003c/code\u003e method of an ad group.\u003c/p\u003e\n"],["\u003cp\u003eProvides methods to iterate through, order, and filter negative keywords based on criteria like text, match type, or ad group/campaign status.\u003c/p\u003e\n"],["\u003cp\u003eUses a selector to define the criteria for fetching negative keywords, enabling flexible querying and retrieval.\u003c/p\u003e\n"],["\u003cp\u003eSupports conditions using operators like \u003ccode\u003e=\u003c/code\u003e, \u003ccode\u003e!=\u003c/code\u003e, \u003ccode\u003eLIKE\u003c/code\u003e, \u003ccode\u003eCONTAINS\u003c/code\u003e, \u003ccode\u003eREGEXP_MATCH\u003c/code\u003e, \u003ccode\u003eIN\u003c/code\u003e, and \u003ccode\u003eNOT IN\u003c/code\u003e to refine the selection of negative keywords.\u003c/p\u003e\n"],["\u003cp\u003eAllows limiting the number of returned entities using \u003ccode\u003ewithLimit()\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# AdsApp.NegativeKeywordSelector\n\nFetches negative keywords (except from shared libraries).\n\nTypical usage:\n\n```gdscript\nvar adGroup = AdsApp.adGroups().get().next();\nvar negativeKeywordSelector = adGroup.negativeKeywords();\n\nvar negativeKeywordIterator = negativeKeywordSelector.get();\nwhile (negativeKeywordIterator.hasNext()) {\n var negativeKeyword = negativeKeywordIterator.next();\n}\n```\nRelated:\n\n- [NegativeKeywordIterator](/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeyworditerator)\n- [NegativeKeyword](/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeyword)\n\n### Methods:\n\n| Member | Type | Description |\n|------------------------------------------------------|------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|\n| [get()](#get) | [AdsApp.NegativeKeywordIterator](/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeyworditerator) | Fetches the requested negative keywords and returns an iterator. |\n| [orderBy(orderBy)](#orderBy_orderBy) | [AdsApp.NegativeKeywordSelector](/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeywordselector) | Specifies the ordering of the resulting entities. |\n| [withCondition(condition)](#withCondition_condition) | [AdsApp.NegativeKeywordSelector](/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeywordselector) | Adds the specified condition to the selector in order to narrow down the results. |\n| [withLimit(limit)](#withLimit_limit) | [AdsApp.NegativeKeywordSelector](/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeywordselector) | Specifies limit for the selector to use. |\n\n`get()`\n-------\n\nFetches the requested negative keywords and returns an iterator.\n\n### Return values:\n\n| Type | Description |\n|------------------------------------------------------------------------------------------------------------|----------------------------------------------|\n| [AdsApp.NegativeKeywordIterator](/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeyworditerator) | Iterator of the requested negative keywords. |\n\n`orderBy(orderBy)`\n------------------\n\nSpecifies the ordering of the resulting entities. `orderBy` parameter can have one of the following forms:\n\n- `orderBy(\"ad_group_criterion.keyword.text\")` - orders results by text, in ascending order.\n- `orderBy(\"ad_group_criterion.keyword.text ASC\")` - orders results by text, in ascending order.\n- `orderBy(\"ad_group_criterion.keyword.text DESC\")` - orders results by text, in descending order.\n\nSee [NegativeKeywordSelector.withCondition(String)](/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeywordselector#withCondition_condition)\nfor enumeration of columns that can be used.\n\n`orderBy()` may be called multiple times. Consider the\nfollowing example:\n\n```carbon\nselector = selector.\n .orderBy(\"ad_group_criterion.keyword.text\")\n .orderBy(\"ad_group_criterion.keyword.match_type\");\n```\n\nThe results will be ordered by text in ascending order. Results with\nequal text value will be ordered by match type in ascending order.\n\n### Arguments:\n\n| Name | Type | Description |\n|---------|----------|--------------------|\n| orderBy | `String` | Ordering to apply. |\n\n### Return values:\n\n| Type | Description |\n|------------------------------------------------------------------------------------------------------------|-------------------------------------|\n| [AdsApp.NegativeKeywordSelector](/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeywordselector) | The selector with ordering applied. |\n\n`withCondition(condition)`\n--------------------------\n\nAdds the specified condition to the selector in order to narrow down the results.\n\nMultiple conditions may be added to the same selector:\n\n```carbon\nselector = selector\n .withCondition(\"ad_group_criterion.keyword.text REGEXP_MATCH 'a.*'\")\n .withCondition(\"ad_group_criterion.keyword.match_type = BROAD\");\n```\nAll specified conditions are `AND`-ed together. The above example will retrieve negative keywords that start with the letter 'a' and are of broad match type.\n\nThe parameter to be passed into this method must be of the following\nform:\n\n```scdoc\n\"COLUMN_NAME OPERATOR VALUE\"\n```\n\n#### Operators\n\nThe operator that can be used in a condition depends on the type of column.\n\n- For `String` columns (e.g. ad_group_criterion.keyword.text): **```scdoc\n = != (NOT) (LIKE | CONTAINS | REGEXP_MATCH)\n ```**\n- For `Enumeration` columns (ones that can only take one value from a pre-defined list, such as ad_group_criterion.keyword.match_type): **```text\n = != IN () NOT IN ()\n ```**\n\nConditions using `IN`, `NOT IN`, `CONTAINS\nALL`, `CONTAINS ANY` and `CONTAINS NONE` operators look as follows: \n\n```carbon\nwithCondition(\"ad_group_criterion.keyword.match_type IN (Value1, Value2)\")\n```\n\n#### Columns\n\nAll column names are case-sensitive, and so are all values of enumerated\ncolumns (such as KeywordMatchType)\n\n| Column | Type | Example |\n|---------------------------------------|---------------------------------------------|-------------------------------------------------------------------------------------------------------------|\n| ***Negative keyword attributes*** |||\n| ad_group_criterion.keyword.text | String | `withCondition(\"ad_group_criterion.keyword.text REGEXP_MATCH 'leather.*'\")` |\n| ad_group_criterion.keyword.match_type | Enumeration: `BROAD`, `EXACT`, `PHRASE` | `withCondition(\"ad_group_criterion.keyword.match_type = PHRASE\")` |\n| ad_group.name | String | `withCondition(\"ad_group.name REGEXP_MATCH '.*shoes.*'\")` |\n| ad_group.status | Enumeration: `ENABLED`, `PAUSED`, `REMOVED` | `withCondition(\"ad_group.status = ENABLED\")`. Use to fetch negative keywords from only `ENABLED` ad groups. |\n| campaign.name | String | `withCondition(\"campaign.name REGEXP_MATCH '.*promotion.*'\")` |\n| campaign.status | Enumeration: `ENABLED`, `PAUSED`, `REMOVED` | `withCondition(\"campaign.status = ENABLED\")`. Use to fetch negative keywords from only `ENABLED` campaigns. |\n\n### Arguments:\n\n| Name | Type | Description |\n|-----------|----------|-----------------------------------|\n| condition | `String` | Condition to add to the selector. |\n\n### Return values:\n\n| Type | Description |\n|------------------------------------------------------------------------------------------------------------|------------------------------------------|\n| [AdsApp.NegativeKeywordSelector](/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeywordselector) | The selector with the condition applied. |\n\n`withLimit(limit)`\n------------------\n\nSpecifies limit for the selector to use. For instance, `withLimit(50)` returns only the first 50 entities.\n\n### Arguments:\n\n| Name | Type | Description |\n|-------|-------|------------------------------|\n| limit | `int` | How many entities to return. |\n\n### Return values:\n\n| Type | Description |\n|------------------------------------------------------------------------------------------------------------|----------------------------------|\n| [AdsApp.NegativeKeywordSelector](/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeywordselector) | The selector with limit applied. |"]]