Parole chiave escluse
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Aggiungi parola chiave esclusa a una campagna
function addNegativeKeywordToCampaign(keyword, campaignName) {
const campaignIterator = AdsApp.campaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (campaignIterator.hasNext()) {
const campaign = campaignIterator.next();
campaign.createNegativeKeyword(keyword);
} else {
throw new Error(`Cannot find campaign with the name '${campaignName}'`);
}
}
Ottieni le parole chiave escluse di una campagna
function getNegativeKeywordsForCampaign(campaignName) {
const campaignIterator = AdsApp.campaigns()
.withCondition(`campaign.name = "${campaignName}"`)
.get();
if (campaignIterator.hasNext()) {
const campaign = campaignIterator.next();
const negativeKeywordIterator = campaign.negativeKeywords().get();
console.log(`Found ${negativeKeywordIterator.totalNumEntities()} negative keywords.`);
return negativeKeywordIterator;
} else {
throw new Error(`Cannot find campaign with the name '${campaignName}'`);
}
}
Aggiungi una parola chiave esclusa a un gruppo di annunci
function addNegativeKeywordToAdGroup(keyword, adGroupName) {
const adGroupIterator = AdsApp.adGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
if (!adGroupIterator.hasNext()) {
throw new Error(`Cannot find ad group with the name '${adGroupName}'`);
}
if (adGroupIterator.totalNumEntities() > 1) {
console.warn(`Found more than one ad group named '${adGroupName}', using the first one.`);
}
const adGroup = adGroupIterator.next();
adGroup.createNegativeKeyword(keyword);
}
Ottieni le parole chiave escluse di un gruppo di annunci
function getNegativeKeywordsForAdGroup(adGroupName) {
const adGroupIterator = AdsApp.adGroups()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
if (!adGroupIterator.hasNext()) {
throw new Error(`Cannot find ad group with the name '${adGroupName}'`);
}
if (adGroupIterator.totalNumEntities() > 1) {
console.warn(`Found more than one ad group named '${adGroupName}', using the first one.`);
}
const adGroup = adGroupIterator.next();
const negativeKeywordIterator = adGroup.negativeKeywords().get();
if (negativeKeywordIterator.hasNext()) {
const negativeKeyword = negativeKeywordIterator.next();
console.log(`Found ${negativeKeywordIterator.totalNumEntities()} negative keywords.`);
return negativeKeywordIterator;
}
}
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 documentation provides Google Ads scripts for managing negative keywords at both the campaign and ad group levels."],["It includes functions to add negative keywords and retrieve existing negative keywords for campaigns or ad groups using their respective names."],["When searching for ad groups by name, if multiple ad groups share the same name, the script will use the first one it encounters and issue a warning."],["These functions are built upon the Google Ads Scripts API, utilizing methods like `createNegativeKeyword` and iterators to interact with campaign and ad group entities."],["Error handling is incorporated to notify users if the specified campaign or ad group is not found."]]],[]]