Parole chiave
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Crea una parola chiave in un gruppo di annunci esistente
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;
}
Metti in pausa una parola chiave esistente di un gruppo di annunci
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();
}
}
Ottieni tutte le parole chiave di un gruppo di annunci
function getKeywordsInAdGroup(adGroupName) {
const keywordIterator = AdsApp.keywords()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
console.log(`Ad Group "${adGroupName}" has ${
keywordIterator.totalNumEntities()} keywords`);
return keywordIterator;
}
Registra statistiche per tutte le parole chiave di un gruppo di annunci
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('--------------------');
}
}
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2024-09-12 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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."]]],[]]