Bütçe sayısı
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Kampanya bütçesi belirleyin
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);
}
Kampanya bütçesini alma
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();
}
Kampanya bütçesi ayrıntılarını günlüğe kaydet
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());
}
}
}
Aksi belirtilmediği sürece bu sayfanın içeriği Creative Commons Atıf 4.0 Lisansı altında ve kod örnekleri Apache 2.0 Lisansı altında lisanslanmıştır. Ayrıntılı bilgi için Google Developers Site Politikaları'na göz atın. Java, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-08-21 UTC.
[null,null,["Son güncelleme tarihi: 2025-08-21 UTC."],[[["\u003cp\u003eThese Google Ads scripts provide functions to set, get, and log details about campaign budgets.\u003c/p\u003e\n"],["\u003cp\u003eThe scripts allow you to find a campaign by name and modify its budget amount.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003elogBudgetDetails\u003c/code\u003e provides detailed information on a campaign's budget, including delivery method, shared status, and associated campaigns if it's a shared budget.\u003c/p\u003e\n"],["\u003cp\u003eError handling is included to identify when a campaign with the specified name cannot be found.\u003c/p\u003e\n"]]],[],null,["# Budgets\n\nSet a campaign budget\n---------------------\n\n```gdscript\nfunction setCampaignBudget(name, amount) {\n const campaignIterator = AdsApp.campaigns()\n .withCondition(`campaign.name = '${name}'`)\n .get();\n if (!campaignIterator.hasNext()) {\n throw new Error(`No campaign with name '${name}' found.`);\n }\n const campaign = campaignIterator.next();\n campaign.getBudget().setAmount(amount);\n}\n```\n\nGet campaign budget\n-------------------\n\n```gdscript\nfunction getBudgetForCampaign(campaignName) {\n const campaignIterator = AdsApp.campaigns()\n .withCondition(`campaign.name = '${name}'`)\n .get();\n if (!campaignIterator.hasNext()) {\n throw new Error(`No campaign with name '${name}' found.`);\n }\n const campaign = campaignIterator.next();\n return campaign.getBudget();\n}\n```\n\nLog campaign budget details\n---------------------------\n\n```gdscript\nfunction logBudgetDetails(campaignName) {\n const campaignIterator = AdsApp.campaigns()\n .withCondition(`campaign.name = '${campaignName}'`)\n .get();\n if (!campaignIterator.hasNext()) {\n throw new Error(`No campaign with name '${campaignName}' found.`);\n }\n const campaign = campaignIterator.next();\n const budget = campaign.getBudget();\n\n console.log(`Budget amount: ${budget.getAmount()}`);\n console.log(`Delivery method: ${budget.getDeliveryMethod()}`);\n console.log(`Explicitly shared: ${budget.isExplicitlyShared()}`);\n\n // If this is a shared budget, log all the associated campaigns.\n // If this is not a shared budget, don't bother since the only associated\n // campaign is the one specified by 'campaignName'.\n if (budget.isExplicitlyShared()) {\n const budgetCampaignIterator = budget.campaigns().get();\n console.log(`=======`);\n console.log(`Associated campaigns (${budgetCampaignIterator.totalNumEntities()}):`);\n\n for (const associatedCampaign of budgetCampaignIterator) {\n console.log(associatedCampaign.getName());\n }\n }\n}\n```"]]