So the code ended like:

// Main Configuration
const config = {
 sheets: [
 {
 name: "Search Ok",
 propertyId: "250883812",
 cells: {
 startDate: "H3",
 endDate: "I3",
 lnknme: "H2"
 }
 },
 {
 name: "Search LGDV",
 propertyId: "353343144",
 cells: {
 startDate: "H3",
 endDate: "I3",
 lnknme: "H2"
 }
 }
 ],
 options: {
 dateRanges: [{ startDate: "", endDate: "" }],
 metrics: [
 { name: "averageSessionDuration" },
 { name: "bounceRate" },
 { name: "engagementRate" },
 { name: "newUsers" },
 { name: "screenPageViews" },
 { name: "totalUsers" }
 ],
 dimensions: [{ name: "pagePath" }, { name: "Date" }],
 dimensionFilter: {
 filter: {
 stringFilter: { value: "", matchType: "MATCH\_TYPE\_UNSPECIFIED" },
 fieldName: "pagePath"
 }
 }
 }
};

// Utility Functions

/\*\*
 \* Converts date format from YYYYMMDD to YYYY-MM-DD
 \* @param {string} date - The date in YYYYMMDD format
 \* @returns {string} - The date in YYYY-MM-DD format
 \*/
function convertDateFormat(date) {
 const year = date.substring(0, 4);
 const month = date.substring(4, 6);
 const day = date.substring(6, 8);
 return `${year}-${month}-${day}`;
}

/\*\*
 \* Fetches data from Google Analytics API
 \* @param {Object} sheetConfig - The sheet configuration
 \* @returns {Object} - Parsed JSON response from the API
 \*/
function fetchData(sheetConfig, options) {
 const response = UrlFetchApp.fetch(
 `https://analyticsdata.googleapis.com/v1beta/properties/${sheetConfig.propertyId}:runReport`,
 {
 method: 'POST',
 muteHttpExceptions: true,
 headers: {
 'Authorization': `Bearer ${ScriptApp.getOAuthToken()}`
 },
 contentType: 'application/json; charset=utf-8',
 payload: JSON.stringify(options)
 }
 );

 try {
 return JSON.parse(response);
 } catch (error) {
 console.error(`Error fetching data for sheet "${sheetConfig.name}":`, error);
 return null;
 }
}

/\*\*
 \* Processes the fetched data and populates the sheet
 \* @param {Object} sheetConfig - The sheet configuration
 \* @param {Object} json - The parsed JSON data from the API
 \*/
function processAndPopulateSheet(sheetConfig, json) {
 const spreadsheet = SpreadsheetApp.getActive();
 const sheet = spreadsheet.getSheetByName(sheetConfig.name);
 const arrayData = [];

 if (json === null) {
 console.error(`No data to process for sheet "${sheetConfig.name}"`);
 return;
 }
 for (let i = 0; i < json.rows.length; i++) {
 const lnk = json.rows[i].dimensionValues[0].value;
 const dte = json.rows[i].dimensionValues[1].value;
 const avd = json.rows[i].metricValues[0].value;
 const bor = json.rows[i].metricValues[1].value;
 const vws = json.rows[i].metricValues[4].value;

 const formattedDate = convertDateFormat(dte);
 const formattedBounceRate = parseFloat(bor).toFixed(2);
 const formattedAvgSessionDuration = parseFloat(avd).toFixed(2);

 const objeto = [lnk, formattedDate, formattedAvgSessionDuration, formattedBounceRate, vws];
 arrayData.push(objeto);
 }

 sheet.getRange(2, 1, arrayData.length, 5).setValues(arrayData);
}

// Main function
function main() {
 config.sheets.forEach(sheetConfig => {
 const spreadsheet = SpreadsheetApp.getActive();
 const sheet = spreadsheet.getSheetByName(sheetConfig.name);

 const startDate = sheet.getRange(sheetConfig.cells.startDate).getValue();
 const endDate = sheet.getRange(sheetConfig.cells.endDate).getValue();
 const lnknme = sheet.getRange(sheetConfig.cells.lnknme).getValue();

 const options = JSON.parse(JSON.stringify(config.options));
 options.dateRanges[0].startDate = Utilities.formatDate(startDate, "GMT", "yyyy-MM-dd");
 options.dateRanges[0].endDate = Utilities.formatDate(endDate, "GMT", "yyyy-MM-dd");
 options.dimensionFilter.filter.stringFilter.value = lnknme;

 const json = fetchData(sheetConfig, options);
 processAndPopulateSheet(sheetConfig, json);
 });
}

// Run the main function
main();
Any great improvements that can be done?
따라서 코드는 다음과 같이 끝납니다:// 메인 구성const config = { 시트 [ { 이름: "검색 확인", propertyId: "250883812", cells: { startDate: "H3", endDate: "I3", lnknme: "H2" } }, { name: "LGDV 검색", propertyId: "353343144", cells: { startDate: "H3", endDate: "I3", lnknme: "H2" } } ], 옵션: { dateRanges: [{ startDate: "", endDate: "" }], metrics: [ { name: "평균 세션 지속 시간" }, { name: "bounceRate" }, { name: "참여율" }, { name: "newUsers" }, { name: "screenPageViews" }, { name: "totalUsers" } ], 차원: [{ name: "pagePath" }, { name: "Date" }], dimensionFilter: { 필터: { 문자열 필터: { value: "", matchType: "일치\_type\_지정되지 않음" }, fieldName: "페이지 경로" } } }};// 유틸리티 함수/\*\* \* 날짜 형식을 YYYYMMDD에서 YYYY-MM-DD로 변환합니다. \* @param {string} date - YYYYMMDD 형식의 날짜 \* @returns {string} - YYYY-MM-DD 형식의 날짜 \*/함수 convertDateFormat(date) { const year = date.substring(0, 4); const month = date.substring(4, 6); const day = date.substring(6, 8); 반환 `${연도}-${월}-${일}`;}/\*\* \* 구글 애널리틱스 API에서 데이터를 가져옵니다. \* @param {Object} sheetConfig - 시트 구성 \* @returns {Object} - API에서 파싱된 JSON 응답 \*/함수 fetchData(sheetConfig, options) { const response = UrlFetchApp.fetch( `https://analyticsdata.googleapis.com/v1beta/properties/${sheetConfig.propertyId}:runReport`, { 메소드: 'POST', muteHttpExceptions: true, headers: { 'Authorization': `발신자 ${ScriptApp.getOAuthToken()}` }, contentType: 'application/json; charset=utf-8', payload: JSON.stringify(options) } ); try { 반환 JSON.parse(response); } catch (error) { console.error(``시트 "${sheetConfig.name}":`에 대한 데이터 가져오기 오류 발생``, error); null을 반환합니다; }}/\*\* \* 가져온 데이터를 처리하고 시트를 채웁니다. \* @param {Object} sheetConfig - 시트 구성 \* @param {Object} json - API에서 파싱된 JSON 데이터 \*/함수 processAndPopulateSheet(sheetConfig, json) { const spreadsheet = SpreadsheetApp.getActive(); const sheet = spreadsheet.getSheetByName(sheetConfig.name); const arrayData = []; if (json === null) { console.error(``시트 "${sheetConfig.name}"에 대해 처리할 데이터가 없습니다``); return; } for (let i = 0; i < json.rows.length; i++) { const lnk = json.rows[i].dimensionValues[0].value; const dte = json.rows[i].dimensionValues[1].value; const avd = json.rows[i].metricValues[0].value; const bor = json.rows[i].metricValues[1].value; const vws = json.rows[i].metricValues[4].value; const formattedDate = convertDateFormat(dte); const formattedBounceRate = parseFloat(bor).toFixed(2); const formattedAvgSessionDuration = parseFloat(avd).toFixed(2); const objeto = [lnk, formattedDate, formattedAvgSessionDuration, formattedBounceRate, vws]; arrayData.push(objeto); } sheet.getRange(2, 1, arrayData.length, 5).setValues(arrayData);}// 메인 함수function main() { config.sheets.forEach(sheetConfig => { const spreadsheet = SpreadsheetApp.getActive(); const sheet = spreadsheet.getSheetByName(sheetConfig.name); const startDate = sheet.getRange(sheetConfig.cells.startDate).getValue(); const endDate = sheet.getRange(sheetConfig.cells.endDate).getValue(); const lnknme = sheet.getRange(sheetConfig.cells.lnknme).getValue(); const options = JSON.parse(JSON.stringify(config.options)); options.dateRanges[0].startDate = Utilities.formatDate(startDate, "GMT", "yyyy-MM-dd"); options.dateRanges[0].endDate = Utilities.formatDate(endDate, "GMT", "yyyy-MM-dd"); options.dimensionFilter.filter.stringFilter.value = lnknme; const json = fetchData(sheetConfig, options); processAndPopulateSheet(sheetConfig, json); });}// 메인 함수 실행main();개선할 수 있는 부분이 있나요?