Problem with extract products from shopping campaign.

22 views
Skip to first unread message

Florian - Visitic

unread,
Jan 18, 2022, 5:49:56 AMJan 18
to Google Ads Scripts Forum
Hello, i've got a problem with this script. 
Error : Column 'Clics' is not valid for report type SHOPPING_PERFORMANCE_REPORT. Double-check your SELECT clause. (file Code.gs, line 23)

Thank you.

// Copy the link of the new sheet and paste it below -
var SPREADSHEET_URL = "link of my spreadsheet";
// Enter your filters below, for multiple filters use AND clause. E.g. Impressions > 100 AND Clics < 1
// Currently default filter is Clics < 1 i.e. Zero Clicks
var FILTERS = "Impressions > 100 AND Clics < 1";
// 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,
Jan 19, 2022, 1:35:59 AMJan 19
to adwords...@googlegroups.com
Hi there,

Thank you for reaching out to us.

For us to assist you further, could you please provide the following details via Reply privately to author option?
  • CID
  • Script Name
  • Shareable link of the spreadsheet being used in the script (if any)
In case you encounter an error when using the mentioned option, you can send the requested information on this email (googleadsscr...@google.com) instead, then let us know here once sent.

Regards,
Google Logo
Teejay Wennie Pimentel
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2VMuAP:ref
Reply all
Reply to author
Forward
Message has been deleted
0 new messages