Skip to content

Instantly share code, notes, and snippets.

@adhummer
Created June 12, 2015 15:23
Show Gist options
  • Save adhummer/efc1ced037affc3f12eb to your computer and use it in GitHub Desktop.
Save adhummer/efc1ced037affc3f12eb to your computer and use it in GitHub Desktop.
Daily Healthy Check Impression v1
// EMAIL FIELDS
var _mailto = '[email protected]';
var _subject = 'Account Review Needed - ';
var _htmlBody = '<h1>Account Review Required</h1>';
var _isEmailRequired = false;
//PARAMETERS CHECKED
var _impressionsTreshold = 1;
var _clickTreshold = 0;
var _conversionTreshold = 0;
var _checkWsmAccountsOnly = false;
var timeframe = 'YESTERDAY';
//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 yesterday: "
+ impressions + ".</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