سرویس داده تجزیه و تحلیل
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
سرویس Analytics Data به شما امکان میدهد از Google Analytics Data API نسخه ۱ در Google Apps Script استفاده کنید. این API به کاربران Google Analytics دسترسی برنامهریزیشده به دادههای گزارش Google Analytics میدهد.
مانند تمام سرویسهای پیشرفته در Apps Script، سرویس AnalyticsData از همان اشیاء، متدها و پارامترهای API عمومی استفاده میکند. برای اطلاعات بیشتر، به بخش «نحوه تعیین امضاهای متد» مراجعه کنید.
/** * Runs a report of a Google Analytics 4 property ID. Creates a sheet with the * report. */functionrunReport(){/** * TODO(developer): Uncomment this variable and replace with your * Google Analytics 4 property ID before running the sample. */constpropertyId="YOUR-GA4-PROPERTY-ID";try{constmetric=AnalyticsData.newMetric();metric.name="activeUsers";constdimension=AnalyticsData.newDimension();dimension.name="city";constdateRange=AnalyticsData.newDateRange();dateRange.startDate="2020-03-31";dateRange.endDate="today";constrequest=AnalyticsData.newRunReportRequest();request.dimensions=[dimension];request.metrics=[metric];request.dateRanges=dateRange;constreport=AnalyticsData.Properties.runReport(request,`properties/${propertyId}`,);if(!report.rows){console.log("No rows returned.");return;}constspreadsheet=SpreadsheetApp.create("Google Analytics Report");constsheet=spreadsheet.getActiveSheet();// Append the headers.constdimensionHeaders=report.dimensionHeaders.map((dimensionHeader)=>{returndimensionHeader.name;});constmetricHeaders=report.metricHeaders.map((metricHeader)=>{returnmetricHeader.name;});constheaders=[...dimensionHeaders,...metricHeaders];sheet.appendRow(headers);// Append the results.constrows=report.rows.map((row)=>{constdimensionValues=row.dimensionValues.map((dimensionValue)=>{returndimensionValue.value;});constmetricValues=row.metricValues.map((metricValues)=>{returnmetricValues.value;});return[...dimensionValues,...metricValues];});sheet.getRange(2,1,report.rows.length,headers.length).setValues(rows);console.log("Report spreadsheet created: %s",spreadsheet.getUrl());}catch(e){// TODO (Developer) - Handle exceptionconsole.log("Failed with error: %s",e.error);}}
تاریخ آخرین بهروزرسانی 2026-04-30 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2026-04-30 بهوقت ساعت هماهنگ جهانی."],[],[]]