Created
January 28, 2015 16:03
-
-
Save adhummer/c062a15a62457959f21d to your computer and use it in GitHub Desktop.
Daily basic health check for adwords accounts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 = 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>" | |
} | |
clicks = stats.getClicks(); | |
if (clicks <= _clickTreshold) { | |
_isEmailRequired = true; | |
_htmlBody += "<p>Clicks yesterday: " | |
+ clicks + ".</p>" | |
} | |
conversions = stats.getConvertedClicks(); | |
if (conversions < _conversionTreshold) { | |
_isEmailRequired = true; | |
_htmlBody += "<p>Conversions yesterday: " | |
+ 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