Ключевые слова
Оптимизируйте свои подборки Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Создайте ключевое слово в существующей группе объявлений.
function createHatsKeyword() { // This example snippet creates a broad match keyword for "hats". Keywords // can be created with many optional settings, such as a max CPC bid, tracking // URL templates, and more. Please customize this example for your specific // use case. For more details about keyword builder options, see // https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_keywordbuilder. const adGroupName = 'Ad group 1'; const adGroupIterator = AdsApp.adGroups() .withCondition(`ad_group.name = "${adGroupName}"`) .get(); if (!adGroupIterator.hasNext()) { throw new Error(`No ad group found with name "${adGroupName}"`); } const adGroup = adGroupIterator.next(); if (adGroupIterator.totalNumEntities() > 1) { console.warn(`Multiple ad groups named "${adGroupName}" found. Using the one from campaign "${adGroup.getCampaign().getName()}".`); } const keywordOperation = adGroup.newKeywordBuilder() .withText('hats') .withCpc(1.25) .withFinalUrl('https://www.example.com') .build(); return keywordOperation; }
Приостановить существующее ключевое слово в группе объявлений
function pauseKeywordInAdGroup(keywordText, adGroupName) { const adGroupIterator = AdsApp.adGroups() .withCondition(`ad_group.name = "${adGroupName}"`) .get(); if (!adGroupIterator.hasNext()) { throw new Error(`No ad group found with name "${adGroupName}"`); } const adGroup = adGroupIterator.next(); if (adGroupIterator.totalNumEntities() > 1) { console.warn(`Multiple ad groups named "${adGroupName}" found. Using the one from campaign "${adGroup.getCampaign().getName()}".`); } for (const keyword of adGroup.keywords().withCondition( `ad_group_criterion.keyword.text = "${keywordText}"`)) { keyword.pause(); } }
Получить все ключевые слова в группе объявлений
function getKeywordsInAdGroup(adGroupName) { const keywordIterator = AdsApp.keywords() .withCondition(`ad_group.name = "${adGroupName}"`) .get(); console.log(`Ad Group "${adGroupName}" has ${ keywordIterator.totalNumEntities()} keywords`); return keywordIterator; }
Записывать статистику по всем ключевым словам в группе объявлений.
function logKeywordStatsForAdGroup() { // This example snippet prints click and impression statistics to the script // execution log. Please customize this example for your specific use case. // For all the kinds of statistics that can be logged, see // https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_stats. const adGroupName = 'Ad group 1'; const adGroupIterator = AdsApp.adGroups() .withCondition(`ad_group.name = "${adGroupName}"`) .get(); if (!adGroupIterator.hasNext()) { throw new Error(`No ad group found with name "${adGroupName}"`); } const adGroup = adGroupIterator.next(); if (adGroupIterator.totalNumEntities() > 1) { console.warn(`Multiple ad groups named "${adGroupName}" found. Using the one from campaign "${adGroup.getCampaign().getName()}".`); } for (const keyword of adGroup.keywords()) { let stats = keyword.getStatsFor('LAST_MONTH'); console.log(`Ad Group: "${adGroup.getName()}"`); console.log(`Keyword: "${keyword.getText()}"`); console.log(`Clicks: ${stats.getClicks()}`); console.log(`Impressions: ${stats.getImpressions()}`); console.log('--------------------'); } }
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-07-29 UTC.
[[["Прост для понимания","easyToUnderstand","thumb-up"],["Помог мне решить мою проблему","solvedMyProblem","thumb-up"],["Другое","otherUp","thumb-up"]],[["Отсутствует нужная мне информация","missingTheInformationINeed","thumb-down"],["Слишком сложен/слишком много шагов","tooComplicatedTooManySteps","thumb-down"],["Устарел","outOfDate","thumb-down"],["Проблема с переводом текста","translationIssue","thumb-down"],["Проблемы образцов/кода","samplesCodeIssue","thumb-down"],["Другое","otherDown","thumb-down"]],["Последнее обновление: 2025-07-29 UTC."],[[["This webpage provides Google Ads Scripts examples for managing keywords within an ad group."],["You can use these scripts to create new keywords, specifying attributes like match type, bid, and final URL."],["The scripts also demonstrate how to pause existing keywords based on their text and ad group."],["You can retrieve and iterate through all keywords within a specific ad group using the provided functions."],["Examples for logging key performance statistics, such as clicks and impressions, for keywords in an ad group are included."]]],[]]