Last active
August 29, 2015 14:10
-
-
Save daniel-c05/2f8c2628f992d634aef4 to your computer and use it in GitHub Desktop.
AdWords Scripts - Account Health Check
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 = 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