Wenn Sie sich mit anderen Nutzern über unsere Produkte austauschen und Feedback geben möchten, können Sie dem offiziellen Google Ads-Discord-Kanal auf dem Server der
Google Advertising and Measurement Community beitreten.
Budgets
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Kampagnenbudget festlegen
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);
}
Kampagnenbudget abrufen
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();
}
Details zum Kampagnenbudget protokollieren
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());
}
}
}
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-08-21 (UTC).
[null,null,["Zuletzt aktualisiert: 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```"]]