What Exactly is Campaign Status

15 views
Skip to first unread message

Sanket Dhume

unread,
Feb 20, 2019, 10:01:04 AM2/20/19
to Google Ads Scripts Forum
Hello everybody 

This might not be a core Script-specific question but any guidance is still appreciated. I manage a massive managed account and wanted to build a script that sends out a daily notification when there's a change in campaign status from yesterday to today. I managed to build out a script that records Campaign Status for "DURING TODAY" and "DURING YESTERDAY" in 2 separate GSheet tabs (code for TODAY is pasted below). Eventually I can write a script within the sheet to vlookup both tabs and send out a notification for only those campaigns with changes between the two statuses. 

I realized much later that this only works if Campaign Status is static in Google Ads reporting. Meaning, if Campaign A was 'Paused' on 01-31-2019 and was 'Enabled' on 02-01-2019, when I run the report on 02-01-2019, it needs to show me 'Campaign Status = Paused' for 01-31-2019 and Campaign Status = Enabled' for 02-01-2019. Can somebody validate that this is how it works? Or does it pull real-time campaign status? 

Again, any help would be deeply appreciated. A few hours work of code is on the line (PS. I'm not very skilled at JS, so as you can imagine this was a pretty stressful few hours worth of work!)

Also happy if somebody can suggest a simpler (code-wise) and more reliable way of achieving the same end. 

CODE BELOW: 

var spreadsheet = SpreadsheetApp.openByUrl('INSERT_URL_HERE');
 
function main(){
 
spreadsheet.setSpreadsheetLocale('en');
var sheetSettings = createOrGetSheet(spreadsheet, 'Settings', 0);
var settingRange = sheetSettings.getRange(1,1,1,2);
var sheet = createOrGetSheet(spreadsheet, 'Today', 1);  
 
var report = AdsApp.report(
  " SELECT CampaignName, CampaignId, CampaignStatus, Date" + 
  " FROM CAMPAIGN_PERFORMANCE_REPORT"+
  " WHERE CampaignStatus != REMOVED"+
  " DURING TODAY");
   
report.exportToSheet(sheet);
  Logger.log("Report available at " + spreadsheet.getUrl());
}
//Creating or returning selected sheet 
function createOrGetSheet(reportSpreadsheet, name, position) {
  var sheet = reportSpreadsheet.getSheetByName(name);
  if(sheet == null) {
    return reportSpreadsheet.insertSheet(name,position);
  } else {
    return sheet;
  }   
}

googleadsscrip...@google.com

unread,
Feb 20, 2019, 3:26:28 PM2/20/19
to Sanket Dhume via Google Ads Scripts Forum, Google Ads Scripts Forum
Hello,

Pulling an entity's status from reports will return it's current status regardless of the date range provided. For example, if an entity was paused between 1/30 and 1/31 but is enabled today (2/20), then a report from today will return enabled for that entity even if you specify, 'DURING 20190130, 20190131 '.

However, if you're running a report daily, storing the value of entity's status in a spreadsheet, and comparing the status values between a 'yesterday column' and a 'today column', then the script should still work fine, since yesterday's status has already been stored in the spreadsheet.

Please let me know if you have any other questions on this.

Regards,
Matt
Google Ads Scripts Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_scripts
    https://developers.google.com/google-ads/scripts/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-scripts+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/824b2c16-5344-4ebd-97a8-653a8269ac21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages