لیست کلمات کلیدی منفی
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
یک لیست کلیدواژه منفی با نام دریافت کنید
function getNegativeKeywordList(name) {
const negativeKeywordLists = AdsApp.negativeKeywordLists()
.withCondition(`shared_set.name = "${name}"`)
.get();
if (!negativeKeywordLists.hasNext()) {
throw new Error(`Cannot find negative keyword list with name "${name}"`);
}
return negativeKeywordLists.next();
}
یک لیست کلیدواژه منفی جدید بسازید و آن را به کمپین اضافه کنید
function addNegativeKeywordListToCampaign(campaignName, negativeKeywordListName) {
const negativeKeywordLists = AdsApp.negativeKeywordLists()
.withCondition(`shared_set.name = "${negativeKeywordListName}"`)
.get();
if (!negativeKeywordLists.hasNext()) {
throw new Error(`Cannot find negative keyword list with name "${negativeKeywordListName}"`);
}
const negativeKeywordList = negativeKeywordLists.next();
const campaigns = AdsApp.campaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (!campaigns.hasNext()) {
throw new Error(`Cannot find campaign with the name "${campaignName}"`);
}
const campaign = campaigns.next();
campaign.addNegativeKeywordList(negativeKeywordList);
}
تمام کلمات کلیدی منفی مشترک را در یک لیست کلیدواژه منفی حذف کنید
function removeAllNegativeKeywordsFromList(name) {
const negativeKeywordLists = AdsApp.negativeKeywordLists()
.withCondition(`shared_set.name = "${name}"`)
.get();
if (!negativeKeywordLists.hasNext()) {
throw new Error(`Cannot find negative keyword list with name "${name}"`);
}
const negativeKeywordList = negativeKeywordLists.next();
for (const negativeKeyword of negativeKeywordList.negativeKeywords()) {
negativeKeyword.remove();
}
}
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-21 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-21 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThese Google Ads scripts provide functions to manage negative keyword lists, including retrieving a list by name, adding a list to a campaign, and removing all negative keywords from a list.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetNegativeKeywordList\u003c/code\u003e function retrieves an existing negative keyword list using its name and throws an error if not found.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eaddNegativeKeywordListToCampaign\u003c/code\u003e function associates an existing negative keyword list with a specific campaign, also throwing an error if either the list or campaign is not found.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eremoveAllNegativeKeywordsFromList\u003c/code\u003e function removes all negative keywords within a specified negative keyword list, throwing an error if the list is not found.\u003c/p\u003e\n"]]],[],null,["# Negative Keyword Lists\n\nGet a negative keyword list by name\n-----------------------------------\n\n```gdscript\nfunction getNegativeKeywordList(name) {\n const negativeKeywordLists = AdsApp.negativeKeywordLists()\n .withCondition(`shared_set.name = \"${name}\"`)\n .get();\n if (!negativeKeywordLists.hasNext()) {\n throw new Error(`Cannot find negative keyword list with name \"${name}\"`);\n }\n\n return negativeKeywordLists.next();\n}\n```\n\nConstruct a new negative keyword list and add it to a campaign\n--------------------------------------------------------------\n\n```gdscript\nfunction addNegativeKeywordListToCampaign(campaignName, negativeKeywordListName) {\n const negativeKeywordLists = AdsApp.negativeKeywordLists()\n .withCondition(`shared_set.name = \"${negativeKeywordListName}\"`)\n .get();\n if (!negativeKeywordLists.hasNext()) {\n throw new Error(`Cannot find negative keyword list with name \"${negativeKeywordListName}\"`);\n }\n const negativeKeywordList = negativeKeywordLists.next();\n\n const campaigns = AdsApp.campaigns()\n .withCondition(`campaign.name = \"${campaignName}\"`)\n .get();\n if (!campaigns.hasNext()) {\n throw new Error(`Cannot find campaign with the name \"${campaignName}\"`);\n }\n const campaign = campaigns.next();\n campaign.addNegativeKeywordList(negativeKeywordList);\n}\n```\n\nRemove all the shared negative keywords in an negative keyword list\n-------------------------------------------------------------------\n\n```gdscript\nfunction removeAllNegativeKeywordsFromList(name) {\n const negativeKeywordLists = AdsApp.negativeKeywordLists()\n .withCondition(`shared_set.name = \"${name}\"`)\n .get();\n if (!negativeKeywordLists.hasNext()) {\n throw new Error(`Cannot find negative keyword list with name \"${name}\"`);\n }\n const negativeKeywordList = negativeKeywordLists.next();\n\n for (const negativeKeyword of negativeKeywordList.negativeKeywords()) {\n negativeKeyword.remove();\n }\n}\n```"]]