Budget
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Imposta un budget per la campagna
function setCampaignBudget(name, amount) {
const campaignIterator = AdsApp.campaigns()
.withCondition(`campaign.name = '${name}'`)
.get();
if (!campaignIterator.hasNext()) {
throw new Error(`No campaign with name '${name}' found.`);
}
const campaign = campaignIterator.next();
campaign.getBudget().setAmount(amount);
}
Ottieni budget campagna
function getBudgetForCampaign(campaignName) {
const campaignIterator = AdsApp.campaigns()
.withCondition(`campaign.name = '${name}'`)
.get();
if (!campaignIterator.hasNext()) {
throw new Error(`No campaign with name '${name}' found.`);
}
const campaign = campaignIterator.next();
return campaign.getBudget();
}
Registra dettagli budget campagna
function logBudgetDetails(campaignName) {
const campaignIterator = AdsApp.campaigns()
.withCondition(`campaign.name = '${campaignName}'`)
.get();
if (!campaignIterator.hasNext()) {
throw new Error(`No campaign with name '${campaignName}' found.`);
}
const campaign = campaignIterator.next();
const budget = campaign.getBudget();
console.log(`Budget amount: ${budget.getAmount()}`);
console.log(`Delivery method: ${budget.getDeliveryMethod()}`);
console.log(`Explicitly shared: ${budget.isExplicitlyShared()}`);
// If this is a shared budget, log all the associated campaigns.
// If this is not a shared budget, don't bother since the only associated
// campaign is the one specified by 'campaignName'.
if (budget.isExplicitlyShared()) {
const budgetCampaignIterator = budget.campaigns().get();
console.log(`=======`);
console.log(`Associated campaigns (${budgetCampaignIterator.totalNumEntities()}):`);
for (const associatedCampaign of budgetCampaignIterator) {
console.log(associatedCampaign.getName());
}
}
}
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-11 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-11 UTC."],[],[]]