מילות מפתח
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
יצירה של מילת מפתח בקבוצת מודעות קיימת
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 Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2024-09-12 (שעון 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"]],["עדכון אחרון: 2024-09-12 (שעון 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."]]],[]]