Low Volume SKUs Script

551 views
Skip to first unread message

Growth MKTG Browze

unread,
Feb 16, 2022, 3:53:00 AM2/16/22
to Google Ads Scripts Forum
Hello,
Was trying to run the following script to extract low volume SKUs into the Google Sheet, but had no luck. The script is running with no errors but not populating any data.
Can you please confirm what has to be changed/refined in order for it to work?
Note: The URL of the sheet has been modified for this example. And the name of the sheet used is Custom_Label.

Thanks in advance!

  // Copy the link of the new sheet and paste it below -
var SPREADSHEET_URL ="https://docs.google.com/spreadsheets/";
// Enter your filters below, for multiple filters use AND clause. E.g. Impressions > 100 AND Clicks < 1
// Currently default filter is Clicks < 1 i.e. Zero Clicks
var FILTERS = "Impressions < 50";

// Enter time duration below. Possibilities:
// TODAY | YESTERDAY | LAST_7_DAYS | LAST_WEEK | LAST_BUSINESS_WEEK |
//THIS_MONTH | LAST_MONTH |
// LAST_14_DAYS | LAST_30_DAYS | THIS_WEEK_SUN_TODAY | THIS_WEEK_MON_TODAY | LAST_WEEK_SUN_SAT
// Currently default time duration is set to: LAST_30_DAYS
var TIME_DURATION = "LAST_30_DAYS";
var COUNT_LIMIT = 999999;
function main(){
 
  var products = getFilteredShoppingProducts();
  products.sort(function(a,b){return a[0] > b[0];});
  products = products.slice(0, COUNT_LIMIT);
  pushToSpreadsheet(products);
}
function getFilteredShoppingProducts(){
  var query = "SELECT OfferId FROM SHOPPING_PERFORMANCE_REPORT WHERE " + FILTERS + " DURING "+ TIME_DURATION;
 
  var products = [];
  var count = 0;
  var report = AdWordsApp.report(query);
  var rows = report.rows();
  while (rows.hasNext()){
    var row = rows.next();
    var offer_id = row['OfferId'].toString();
    products.push([offer_id]);
    count+= 1;
  }
 
Logger.log(count);
return products;
}
function pushToSpreadsheet(data){
var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
var sheet = spreadsheet.getSheetByName('Custom_Label');
var lastRow = sheet.getMaxRows();
sheet.getRange('A2:A'+lastRow).clearContent();
var start_row=2;
var endRow=start_row+data.length-1;
var range = sheet.getRange('A'+start_row+':'+'A'+endRow);
if (data.length>0){range.setValues(data);}
return;}
}

Google Ads Scripts Forum Advisor

unread,
Feb 17, 2022, 11:14:00 PM2/17/22
to adwords...@googlegroups.com

Hello,

Thank you for reaching out to us.

So our team can further check on this, can you share to us your customer ID and the script name?

Regards,

Google Logo
Mark Kevin
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2WwBiU:ref

Growth MKTG Browze

unread,
Feb 23, 2022, 9:41:31 AM2/23/22
to Google Ads Scripts Forum on behalf of adsscripts
Hi,
Thanks for getting back to me,
Sure it's 697-759-8158 and the script name is "Low - volume SKU script"

Thanks in advance!

--
-- 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-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/2VQDX000000000000000000000000000000000000000000000R7HFR2004tbwkCpwTYyAcKxsS5DTog%40sfdc.net.

Google Ads Scripts Forum Advisor

unread,
Feb 24, 2022, 1:24:12 AM2/24/22
to adwords...@googlegroups.com

Hello,

 

Maia here, I work along with Mark from the same team. Thank you for getting back to us with the needed details.

 

Upon further checking on your script, in line 41 the getSheetByName method’s parameter is “Custom_Label”. However, the sheet name on your Custom_Label spreadsheet is “Sheet1” instead of the one you have specified on your parameter which is “Custom_Label”.

 

Kindly rename your sheet name to the one you have specified and let us know how it goes.

 

Best Regards,

Google Logo
Angel Maia
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2WwBiU:ref

Growth MKTG Browze

unread,
Feb 25, 2022, 11:01:35 AM2/25/22
to Google Ads Scripts Forum on behalf of adsscripts
Thanks,
Made the change but it's still not working.  
Please confirm what might be the problem.

Thanks


--
-- 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-scrip...@googlegroups.com.

Google Ads Scripts Forum Advisor

unread,
Mar 2, 2022, 4:40:02 AM3/2/22
to adwords...@googlegroups.com

Hello,

I’m James, also a member of the Google Ads Script support team. Thank you for your response.

As per checking the script named `Low - volume SKU script`, I noticed the following error / issues below.

  • There are 2 main functions within your script, see screenshot#1 attached. Having said that, can you please remove the outer main function?
  • On line 41, the declared sheet name under getSheetByName() is ‘Custom_Label’. However, within the given spreadsheet link, I noticed that the name of your sheet is `Sheet1`(see screenshot#2 attached) With that being said, could please try to replace the value given to getSheetByName() with `Sheet1`. Take note the value within getSheetByName() method should be exactly match the sheet name in your spreadsheet.

 

Having said that, can you please try the given options above and observe if the error will persist?

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2WwBiU:ref

Google Ads Scripts Forum Advisor

unread,
Mar 2, 2022, 4:41:02 AM3/2/22
to adwords...@googlegroups.com
screenshot#1.png
screenshot#2.png
Reply all
Reply to author
Forward
0 new messages