Anahtar kelimeler
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Mevcut bir reklam grubunda anahtar kelime oluşturma
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;
}
Bir reklam grubundaki bir anahtar kelimeyi duraklatma
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();
}
}
Bir reklam grubundaki tüm anahtar kelimeleri alma
function getKeywordsInAdGroup(adGroupName) {
const keywordIterator = AdsApp.keywords()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
console.log(`Ad Group "${adGroupName}" has ${
keywordIterator.totalNumEntities()} keywords`);
return keywordIterator;
}
Bir reklam grubundaki tüm anahtar kelimelerin istatistiklerini günlüğe kaydet
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('--------------------');
}
}
Aksi belirtilmediği sürece bu sayfanın içeriği Creative Commons Atıf 4.0 Lisansı altında ve kod örnekleri Apache 2.0 Lisansı altında lisanslanmıştır. Ayrıntılı bilgi için Google Developers Site Politikaları'na göz atın. Java, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-08-21 UTC.
[null,null,["Son güncelleme tarihi: 2025-08-21 UTC."],[[["\u003cp\u003eThis webpage provides Google Ads Scripts examples for managing keywords within an ad group.\u003c/p\u003e\n"],["\u003cp\u003eYou can use these scripts to create new keywords, specifying attributes like match type, bid, and final URL.\u003c/p\u003e\n"],["\u003cp\u003eThe scripts also demonstrate how to pause existing keywords based on their text and ad group.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve and iterate through all keywords within a specific ad group using the provided functions.\u003c/p\u003e\n"],["\u003cp\u003eExamples for logging key performance statistics, such as clicks and impressions, for keywords in an ad group are included.\u003c/p\u003e\n"]]],[],null,["# Keywords\n\nCreate a keyword in an existing ad group\n----------------------------------------\n\n```gdscript\nfunction createHatsKeyword() {\n // This example snippet creates a broad match keyword for \"hats\". Keywords\n // can be created with many optional settings, such as a max CPC bid, tracking\n // URL templates, and more. Please customize this example for your specific\n // use case. For more details about keyword builder options, see\n // https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_keywordbuilder.\n const adGroupName = 'Ad group 1';\n\n const adGroupIterator = AdsApp.adGroups()\n .withCondition(`ad_group.name = \"${adGroupName}\"`)\n .get();\n\n if (!adGroupIterator.hasNext()) {\n throw new Error(`No ad group found with name \"${adGroupName}\"`);\n }\n\n const adGroup = adGroupIterator.next();\n\n if (adGroupIterator.totalNumEntities() \u003e 1) {\n console.warn(`Multiple ad groups named \"${adGroupName}\" found.\nUsing the one from campaign \"${adGroup.getCampaign().getName()}\".`);\n }\n\n const keywordOperation = adGroup.newKeywordBuilder()\n .withText('hats')\n .withCpc(1.25)\n .withFinalUrl('https://www.example.com')\n .build();\n\n return keywordOperation;\n}\n```\n\nPause an existing keyword in an ad group\n----------------------------------------\n\n```gdscript\nfunction pauseKeywordInAdGroup(keywordText, adGroupName) {\n const adGroupIterator = AdsApp.adGroups()\n .withCondition(`ad_group.name = \"${adGroupName}\"`)\n .get();\n\n if (!adGroupIterator.hasNext()) {\n throw new Error(`No ad group found with name \"${adGroupName}\"`);\n }\n\n const adGroup = adGroupIterator.next();\n\n if (adGroupIterator.totalNumEntities() \u003e 1) {\n console.warn(`Multiple ad groups named \"${adGroupName}\" found.\nUsing the one from campaign \"${adGroup.getCampaign().getName()}\".`);\n }\n\n for (const keyword of adGroup.keywords().withCondition(\n `ad_group_criterion.keyword.text = \"${keywordText}\"`)) {\n keyword.pause();\n }\n}\n```\n\nGet all keywords in an ad group\n-------------------------------\n\n```perl6\nfunction getKeywordsInAdGroup(adGroupName) {\n const keywordIterator = AdsApp.keywords()\n .withCondition(`ad_group.name = \"${adGroupName}\"`)\n .get();\n console.log(`Ad Group \"${adGroupName}\" has ${\n keywordIterator.totalNumEntities()} keywords`);\n return keywordIterator;\n}\n```\n\nLog stats for all keywords in an ad group\n-----------------------------------------\n\n```gdscript\nfunction logKeywordStatsForAdGroup() {\n // This example snippet prints click and impression statistics to the script\n // execution log. Please customize this example for your specific use case.\n // For all the kinds of statistics that can be logged, see\n // https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_stats.\n const adGroupName = 'Ad group 1';\n\n const adGroupIterator = AdsApp.adGroups()\n .withCondition(`ad_group.name = \"${adGroupName}\"`)\n .get();\n\n if (!adGroupIterator.hasNext()) {\n throw new Error(`No ad group found with name \"${adGroupName}\"`);\n }\n\n const adGroup = adGroupIterator.next();\n\n if (adGroupIterator.totalNumEntities() \u003e 1) {\n console.warn(`Multiple ad groups named \"${adGroupName}\" found.\nUsing the one from campaign \"${adGroup.getCampaign().getName()}\".`);\n }\n\n for (const keyword of adGroup.keywords()) {\n let stats = keyword.getStatsFor('LAST_MONTH');\n console.log(`Ad Group: \"${adGroup.getName()}\"`);\n console.log(`Keyword: \"${keyword.getText()}\"`);\n console.log(`Clicks: ${stats.getClicks()}`);\n console.log(`Impressions: ${stats.getImpressions()}`);\n console.log('--------------------');\n }\n}\n```"]]