Script to alert me for anomalies in specific campaigns?

424 views
Skip to first unread message

Tyler Thomas

unread,
May 28, 2015, 1:24:26 PM5/28/15
to adwords...@googlegroups.com
I am trying to find a script that will alert me by email when certain anomalies happen inside of a clients account.

Alerts I need:
  • Clicks drop by 50%
  • Impressions drop by 50%
  • Return On Ad Spend drops by 50%

I need these to run at the individual campaign level and to be based off of some past performance (at least the same day of the previous week).

This way I can know if a specific campaign, like shopping, drops in performance on one of those metrics and I can look into the reason why.


Does anyone know of a script like this?

Message has been deleted

Anthony Madrigal

unread,
May 28, 2015, 2:44:19 PM5/28/15
to adwords...@googlegroups.com
Hello,

The Account Anomaly Detector script is a good starting point for what you need to do. The script sends you an e-mail whenever your account is behaving differently than it normally does. Such behavior includes impressions and/or clicks being lower than historical statistics.

Cheers!
Anthony
AdWords Scripts Team

Tyler Thomas

unread,
May 28, 2015, 2:52:31 PM5/28/15
to adwords...@googlegroups.com
Anthony,

Thanks for your reply. I already installed that script but it seems to work at the account level and I need these to work at the campaign level.

Anthony Madrigal

unread,
May 28, 2015, 3:13:27 PM5/28/15
to adwords...@googlegroups.com
Hi,

The AdWords Scripts Solutions page does not provide an anomaly detector on a campaign level. My best suggestion is to use the Account Anomaly Detector script as a starting point and modify it to be compatible for campaigns.

Things you may need to change
  • Report type from ACCOUNT_PERFORMANCE_REPORT to CAMPAIGN_PERFORMANCE_REPORT
  • Whenever the spreadsheet is getting range of account_id so that it grabs the campaign IDs you want
  • The e-mail body 
You will not need to change the variable now since it is just using your account information to grab the time zone.

Hope this helps!

Regards,
Anthony
AdWords Scripts Team

Tyler Thomas

unread,
May 29, 2015, 3:16:21 PM5/29/15
to adwords...@googlegroups.com
Anthony,

I'm not much of a developer. Would you be able to tell me the exact things to change?

I'm assuming there is more since you said "Things you may need to change".

Thanks a lot for the help!

Anthony Madrigal

unread,
May 29, 2015, 4:09:18 PM5/29/15
to adwords...@googlegroups.com
Hey Tyler,

I think the things I mentioned should be enough to get your script working. Below are snippets of what you need to change. 

Report type from ACCOUNT_PERFORMANCE_REPORT to CAMPAIGN_PERFORMANCE_REPORT
Change 
  var today = AdWordsApp.report('SELECT ' + fields +
     
' FROM ACCOUNT_PERFORMANCE_REPORT DURING ' + dateRangeToCheck + ',' +
      dateRangeToCheck
);
 
var past = AdWordsApp.report('SELECT ' + fields +
     
' FROM ACCOUNT_PERFORMANCE_REPORT WHERE DayOfWeek=' +
      DAYS
[now.getDay()].toUpperCase() +
     
' DURING ' + dateRangeToStart + ',' + dateRangeToEnd);

to
  var today = AdWordsApp.report('SELECT ' + fields +
     
' FROM CAMPAIGN_PERFORMANCE_REPORT DURING ' + dateRangeToCheck + ',' +
      dateRangeToCheck
);
 
var past = AdWordsApp.report('SELECT ' + fields +
     
' FROM CAMPAIGN_PERFORMANCE_REPORT WHERE DayOfWeek=' +
      DAYS
[now.getDay()].toUpperCase() +
     
' DURING ' + dateRangeToStart + ',' + dateRangeToEnd);


Whenever the spreadsheet is getting range of account_id, so that it grabs the campaign IDs you want
Change
  spreadsheet.getRangeByName('account_id').setValue(
     
AdWordsApp.currentAccount().getCustomerId());

to
  spreadsheet.getRangeByName('account_id').setValue(
     
AdWordsApp.campaigns().withIds(THE_CAMPAIGN_ID_YOU_WANT).get().next().getId());


The e-mail body 
Change
    MailApp.sendEmail(email,
       
'AdWords Account ' + AdWordsApp.currentAccount().getCustomerId() +
       
' misbehaved.',
       
'Your account ' + AdWordsApp.currentAccount().getCustomerId() +
       
' is not performing as expected today: \n\n' + alertText.join('\n') +
       
'\n\nLog into AdWords and take a look.\n\nAlerts dashboard: ' +
        SPREADSHEET_URL
);

to
    MailApp.sendEmail(email,
       
'AdWords Account ' + AdWordsApp.currentAccount().getCustomerId() +
       
' misbehaved.',
       
'INSERT_EMAIL_BODY_HERE');

Cheers,
Anthony
AdWords Scripts Team
Reply all
Reply to author
Forward
0 new messages