Hi Richard,
For creating a script that will send notification through email when a campaign's current cost reached the daily budget, you may refer to the following instructions below for creating this script.
2.) Then, you may use
getBudget method to get the budget of the campaign and
getCost method to get the current cost of campaign.
3.) You need to create a validation that will verify if the cost exceeds the daily budget.
4.) You may use the
MailApp.sendEmail method inside the condition to send an email notification.
Please refer to the sample scripts below where provided suggestion is implemented.
function main() { var campaignSelector = AdWordsApp .campaigns();
var campaignIterator = campaignSelector.get(); while (campaignIterator.hasNext()) { var campaign = campaignIterator.next(); if(campaign.getStatsFor('TODAY').getCost() > campaign.getBudget()){ MailApp.sendEmail("INSERT_YOUR_RECIPIENT_HERE", "INSERT_EMAIL_SUBJECT_HERE", "INSERT_YOUR_MESSAGE_HERE"); } } }
|
The above script will also send an email even if you change the campaign budget as long as the condition is met. You can modify the script based on your goal such as sending one email only for one script execution.
You can test the sample script by clicking the Preview button. Please let me know if you encounter any issue.
Regards,
Vincent
AdWords Scripts Team