Notifications
Clear all
limit script
Google Ads inquiries
3
Posts
2
Users
0
Reactions
127
Views
0
January 9, 2024 7:09 pm
Topic starter
Is there a google script to stop spending after a daily maximum budget is spent without pausing and reactivating which will kick the ad back to learning phase?
Answer
Add a comment
Add a comment
1 Answer
0
January 9, 2024 7:10 pm
function main() { var campaigns = AdsApp.campaigns().get(); var budgetLimit = YOUR_BUDGET_LIMIT; // Set your daily budget limit here var notificationThreshold = 0.9; // 90% of the budget limit var emailRecipient = 'YOUR_EMAIL_ADDRESS'; while (campaigns.hasNext()) { var campaign = campaigns.next(); var campaignName = campaign.getName(); var stats = campaign.getStatsFor("TODAY"); var cost = stats.getCost(); var budgetProportion = cost / budgetLimit; if (budgetProportion >= notificationThreshold && budgetProportion < 1) { // Send an email notification if the budget is nearing its limit sendEmail(emailRecipient, 'Budget Alert for ' + campaignName, 'The campaign "' + campaignName + '" is nearing its daily budget limit.'); } if (budgetProportion >= 1) { // Proportionally adjust bids var adGroups = campaign.adGroups().get(); while (adGroups.hasNext()) { var adGroup = adGroups.next(); var currentBid = adGroup.bidding().getCpc(); var adjustedBid = currentBid * (1 - budgetProportion); // Adjust the bid based on spend adGroup.bidding().setCpc(adjustedBid); } // Send an email notification about bid adjustment sendEmail(emailRecipient, 'Bid Adjustment for ' + campaignName, 'The bids for campaign "' + campaignName + '" have been adjusted due to budget limit.'); } } } function sendEmail(recipient, subject, body) { MailApp.sendEmail({ to: recipient, subject: subject, body: body, name: 'YOUR_EMAIL_SENDER_NAME' }); }
Add a comment
Add a comment
Forum Jump: