Palabras clave
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Cómo crear una palabra clave en un grupo de anuncios existente
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;
}
Detener una palabra clave existente en un grupo de anuncios
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();
}
}
Obtener todas las palabras clave en un grupo de anuncios
function getKeywordsInAdGroup(adGroupName) {
const keywordIterator = AdsApp.keywords()
.withCondition(`ad_group.name = "${adGroupName}"`)
.get();
console.log(`Ad Group "${adGroupName}" has ${
keywordIterator.totalNumEntities()} keywords`);
return keywordIterator;
}
Registrar estadísticas para todas las palabras clave en un grupo de anuncios
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 que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2024-09-12 (UTC)
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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."]]],[]]