On the topic of Google Ads Script, do you know you can use Google Ads Script to send you email alerts when your campaign metrics go below certain threshold?
Just a recap, if you need the basic of ads script, you can check it out in this article: Ads Script Beginner’s Guide: Setup and run your first script.
The code
Pretty straight forward
Here is a simple code to email you when your budget spend above 80%. So you know when it is time to add more juice to your campaigns.
function main() { var campaignIterator = AdsApp.campaigns().get(); while (campaignIterator.hasNext()) { var campaign = campaignIterator.next(); var budget = campaign.getBudget(); var spent = budget.getAmountSpent(); var limit = budget.getAmount(); if (spent / limit > 0.8) { MailApp.sendEmail("your_email@example.com", "Budget Alert: " + campaign.getName(), "Campaign " + campaign.getName() + " has spent over 80% of its budget."); } } }
Let’s break it down
AdsApp.campaigns().get() --> Create the list of your campaigns.
campaignIterator.hasNext() --> Loop through the campaigns and check for things.
campaignIterator.next() --> Select the next item in the list.
campaign.getBudget() --> As the name suggest, it get the budget. Same with Spent and limit.
MailApp.sendEmail()
: This is the core function to send emails. It takes three arguments:
to
: The recipient's email address.subject
: The email subject line.body
: The email body content.
Conclusion
This is a rather simple and straight forward function. You could create more condition function to send you email alerts to better automate your campaigns and monitoring.
A shameless plug here. I am an advertising professional with a mission to teach others about marketing technology.
If you enjoyed this article, please do consider buying me a coffee here!
Cheers friends!