Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AdWords Scripts - Account Health Check
// EMAIL FIELDS
var _mailto = 'YOUR_EMAIL';
var _subject = 'Account Review Needed - ';
var _htmlBody = '<h1>Account Review Required</h1>';
var _isEmailRequired = false;
//PARAMETERS CHECKED
var _impressionsTreshold = 100;
var _clickTreshold = 10;
var _conversionTreshold = 2;
var _checkWsmAccountsOnly = false;
var timeframe = 'LAST_7_DAYS';
//METRICS
var impressions, clicks, conversions;
function main () {
var currentAccount = AdWordsApp.currentAccount();
var accountName = currentAccount.getName();
_subject += accountName;
_htmlBody += '<h3>' + accountName + ' | '
+ currentAccount.getCustomerId() + '</h3><hr>';
var stats = currentAccount.getStatsFor(timeframe);
impressions = stats.getImpressions();
if (impressions <= _impressionsTreshold) {
_isEmailRequired = true;
_htmlBody += "<p>Impressions for the last 7 days: "
+ impressions + ".</p>"
}
clicks = stats.getClicks();
if (clicks <= _clickTreshold) {
_isEmailRequired = true;
_htmlBody += "<p>Clicks for the last 7 days: "
+ clicks + ".</p>"
}
conversions = stats.getConvertedClicks();
if (conversions <= _conversionTreshold) {
_isEmailRequired = true;
_htmlBody += "<p>Conversions for the last 7 days: "
+ conversions + ".</p>"
}
if (_isEmailRequired) {
_htmlBody += "<h3>Please take action soon.</h3>";
sendEmail();
}
}
function sendEmail () {
MailApp.sendEmail ({
to: _mailto,
subject: _subject,
htmlBody: _htmlBody
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.