I encountered the error - Parsing error. Please check your selector. (file Code.gs, line 25). Yet, I don't know why my code has error.
I found that many people said this is due to the mistake made in the query.
Yet, I am new to Google Ads Script and don't know much about programming...
Please forgive my ignorance and it would be grateful if anyone could help.
function main() {
// The start and end date of the date range
var MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var now = new Date();
var from = new Date(now.getTime() - MILLIS_PER_DAY);
var to = new Date(); - MILLIS_PER_DAY;
var timeZone = AdWordsApp.currentAccount().getTimeZone();
// Add you spreadsheet here
// Select Query - note the and conditions to remove strings such as ">90%", "<10%" and "--" --> remove when editing the query in PBI
var query = 'SELECT Date, CampaignName, AdGroupName, KeywordText, Impressions, Clicks, Conversions, AveragePosition' +
'FROM KEYWORDS_PERFORMANCE_REPORT ' +
'WHERE AdNetworkType2 = SEARCH AND CampaignStatus = ENABLED AND AdGroupStatus = ENABLED' +
'DURING ' + Utilities.formatDate(from, timeZone, 'yyyyMMdd') + ','
+ Utilities.formatDate(to, timeZone, 'yyyyMMdd');
// Check timezone. If you don't want to use account timezone you can change it
// Logger.log(Utilities.formatDate(date, 'Etc/GMT', 'yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\''));
Logger.log(Utilities.formatDate(to, timeZone, 'yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\''));
Logger.log(query);
var report = AdWordsApp.report(query);
report.exportToSheet(spreadsheet.getActiveSheet());
Logger.log("Your Spreadsheet is ready " + spreadsheet.getUrl());
}