Unsampled Reports: list

ต้องมีการให้สิทธิ์

แสดงรายการรายงานที่ไม่ได้เก็บตัวอย่างที่ผู้ใช้มีสิทธิ์เข้าถึง ดูตัวอย่าง

ส่งคำขอ

คำขอ HTTP

GET https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/profiles/profileId/unsampledReports

พารามิเตอร์

ชื่อพารามิเตอร์ ค่า คำอธิบาย
พารามิเตอร์เส้นทาง
accountId string รหัสบัญชีที่ใช้เรียกดูรายงานที่ไม่ได้เก็บตัวอย่าง ต้องเป็นรหัสบัญชีที่เฉพาะเจาะจง ระบบไม่รองรับ ~all
profileId string ดูรหัส (โปรไฟล์) เพื่อเรียกดูรายงานที่ไม่ได้เก็บตัวอย่าง ต้องเป็นรหัสข้อมูลพร็อพเพอร์ตี้ (โปรไฟล์) ที่เฉพาะเจาะจง ระบบไม่รองรับ ~all
webPropertyId string รหัสเว็บพร็อพเพอร์ตี้สำหรับเรียกดูรายงานที่ไม่ได้เก็บตัวอย่าง ต้องเป็นรหัสเว็บพร็อพเพอร์ตี้ที่เฉพาะเจาะจง ระบบไม่รองรับ ~all
พารามิเตอร์การค้นหาที่ไม่บังคับ
max-results integer จำนวนสูงสุดของรายงานที่ไม่ได้เก็บตัวอย่างที่จะรวมไว้ในการตอบกลับนี้
start-index integer ดัชนีของรายงานที่ไม่ได้เก็บตัวอย่างแรกที่ดึงมา ใช้พารามิเตอร์นี้เป็นกลไกการใส่เลขหน้าร่วมกับพารามิเตอร์ max-results

การให้สิทธิ์

คำขอนี้ต้องได้รับการให้สิทธิ์อย่างน้อย 1 ขอบเขตต่อไปนี้ (อ่านเพิ่มเติมเกี่ยวกับการตรวจสอบสิทธิ์และการให้สิทธิ์)

ขอบเขต
https://www.googleapis.com/auth/analytics
https://www.googleapis.com/auth/analytics.edit
https://www.googleapis.com/auth/analytics.readonly

เนื้อหาของคำขอ

อย่าแสดงเนื้อหาของคำขอด้วยวิธีนี้

คำตอบ

หากทำสำเร็จ เมธอดนี้จะแสดงเนื้อหาการตอบสนองที่มีโครงสร้างต่อไปนี้

{
  "kind": "analytics#unsampledReports",
  "username": string,
  "totalResults": integer,
  "startIndex": integer,
  "itemsPerPage": integer,
  "previousLink": string,
  "nextLink": string,
  "items": [
    management.unsampledReports Resource
  ]
}
ชื่อพร็อพเพอร์ตี้ ค่า คำอธิบาย Notes
kind string ประเภทคอลเล็กชัน
username string รหัสอีเมลของผู้ใช้ที่ตรวจสอบสิทธิ์แล้ว
totalResults integer จำนวนผลลัพธ์ทั้งหมดสำหรับข้อความค้นหา โดยไม่คำนึงถึงจำนวนทรัพยากรในผลลัพธ์
startIndex integer ดัชนีเริ่มต้นของทรัพยากร ซึ่งเท่ากับ 1 โดยค่าเริ่มต้น หรือระบุโดยพารามิเตอร์การค้นหา Start-index
itemsPerPage integer จำนวนทรัพยากรสูงสุดที่การตอบกลับมีได้ โดยไม่คำนึงถึงจำนวนทรัพยากรที่แสดงผลจริง ค่าอยู่ในช่วง 1 ถึง 1000 โดยมีค่า 1000 โดยค่าเริ่มต้น หรือมีการระบุโดยพารามิเตอร์การค้นหาผลลัพธ์สูงสุด
items[] list รายการของรายงานที่ไม่ได้เก็บตัวอย่าง

ตัวอย่าง

หมายเหตุ: ตัวอย่างโค้ดที่มีสำหรับวิธีการนี้ไม่ได้แสดงถึงภาษาโปรแกรมที่รองรับทั้งหมด (ดูรายการภาษาที่รองรับได้ในหน้าไลบรารีของไคลเอ็นต์)

Java

ใช้ไลบรารีของไคลเอ็นต์ Java

/*
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Unsampled Reports Developer Guide for details.
 */

/*
 * Example #1:
 * Requests a list of all unsampled reports for the authorized user.
 */

try {
  UnsampledReports reports = analytics.management().
      unsampledReports().list("123456", "UA-123456-1", "7654321").execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}

/*
 * Example 2:
 * The results of the list method are stored in the reports object.
 * The following code shows how to iterate through them.
 */
for (UnsampledReport report : reports.getItems()) {
  System.out.println("Account Id = " + report.getAccountId());
  System.out.println("Property Id  = " + report.getWebPropertyId());
  System.out.println("Report Id = " + report.getId());
  System.out.println("Report Title = " + report.getTitle());
  System.out.println("Report Kind = " + report.getKind());
  System.out.println("Report start-date = " + report.getStartDate());
  System.out.println("Report end-date = " + report.getEndDate());
  System.out.println("Report metric = " + report.getMetrics());
  System.out.println("Report dimensions = " + report.getDimensions());
  System.out.println("Report filters = " + report.getFilters());
  System.out.println("Report Status = " + report.getStatus());
  System.out.println("Report downloadType = " + report.getDownloadType());
  DriveDownloadDetails drive = report.getDriveDownloadDetails();
  CloudStorageDownloadDetails cloud = report.getCloudStorageDownloadDetails();
  System.out.println("Drive Document id = " + drive.getDocumentId());
  System.out.println("Cloud Bucket Id = " + cloud.getBucketId());
  System.out.println("Cloud Object Id = " + cloud.getObjectId());
}

PHP

ใช้ไลบรารีของไคลเอ็นต์ PHP

/**
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Unsampled Reports Developer Guide for details.
 */

/**
 * Example #1:
 * Requests a list of all unsampled reports for the authorized user.
 */
try {
  $reports = $analytics->management_unsampledReports
      ->listManagementUnsampledReports('123456', 'UA-123456-1', '7654321');

} catch (apiServiceException $e) {
  print 'There was an Analytics API service error '
      . $e->getCode() . ':' . $e->getMessage();

} catch (apiException $e) {
  print 'There was a general API error '
      . $e->getCode() . ':' . $e->getMessage();
}


/**
 * Example #2:
 * The results of the list method are stored in the reports object.
 * The following code shows how to iterate through them.
 */
foreach ($reports->getItems() as $report) {
  $drive = $report->getDriveDownloadDetails();
  $cloud = $report->getCloudStorageDownloadDetails();
  $html = <<<HTML
<pre>
Account Id          = {$report->getAccountId()}
Property Id         = {$report->getWebPropertyId()}
Report Id           = {$report->getId()}
Report Title        = {$report->getTitle()}
Report Kind         = {$report->getKind()}
Report start-date   = {$report->getStartDate()}
Report end-date     = {$report->getEndDate()}
Report metric       = {$report->getMetrics()}
Report dimensions   = {$report->getDimensions()}
Report filters      = {$report->getFilters()}
Report Status       = {$report->getStatus()}
Report downloadType = {$report->getDownloadType()}
Drive Document id   = {$drive->getDocumentId()}
Cloud Bucket Id     = {$cloud->getBucketId()}
Cloud Object Id     = {$cloud->getObjectId()}
</pre>

HTML;
  print $html;
}

Python

ใช้ไลบรารีของไคลเอ็นต์ Python

# Note: This code assumes you have an authorized Analytics service object.
# See the Unsampled Reports Developers Guide for details.

# Example #1:
# Requests a list of all Unsampled Reports for the authorized user.
try:
  reports = analytics.management().unsampledReports().list(
      accountId='1234567',
      webPropertyId='UA-1234567-1',
      profileId='7654321'
  ).execute()

except TypeError, error:
  # Handle errors in constructing a query.
  print 'There was an error in constructing your query : %s' % error

except HttpError, error:
  # Handle API errors.
  print ('There was an API error : %s : %s' %
         (error.resp.status, error.resp.reason))


# Example #2:
# The results of the list method are stored in the reports object.
# The following code shows how to iterate through them.
for report in reports.get('items', []):
  driveDownloadDetails = report.get('driveDownloadDetails', {})
  cloudStorageDownloadDetails = report.get('cloudStorageDownloadDetails', {})

  print 'Account Id            = %s' % report.get('accountId')
  print 'Property Id           = %s' % report.get('webPropertyId')
  print 'Report Id             = %s' % report.get('id')
  print 'Report Title          = %s' % report.get('title')
  print 'Report Kind           = %s' % report.get('kind')
  print 'Report start-date = %s' % report.get('start-date')
  print 'Report end-date = %s' % report.get('end-date')
  print 'Report metrics        = %s' % report.get('metrics')
  print 'Report dimensions = %s' % report.get('dimensions')
  print 'Report filters = %s' % report.get('filters')
  print 'Report Status         = %s\n' % report.get('status')
  print 'Report downloadType = %s' % report.get('downloadType')
  print 'Drive Document Id = %s' % driveDownloadDetails.get('document Id')
  print 'Cloud Bucket Id = %s' % cloudStorageDownloadDetails.get('bucketId')
  print 'Cloud Object Id = %s' % cloudStorageDownloadDetails.get('objectId')
  print 'Report Created = %s' % report.get('created')
  print 'Report Updated = %s' % report.get('updated')






JavaScript

ใช้ไลบรารีของไคลเอ็นต์ JavaScript

/*
 * Note: This code assumes you have an authorized Analytics client object.
 * See the Unsampled Reports Developer Guide for details.
 */

/*
 * Example 1:
 * Requests a list of all unsampled reports for the authorized user.
 */
function listUnsampledReports() {
  var request = gapi.client.analytics.management.unsampledReports.list({
    'accountId': '123456',
    'webPropertyId': 'UA-123456-1',
    'profileId': '7654321'
  });
  request.execute(printViews);
}

/*
 * Example 2:
 * The results of the list method are passed as the results object.
 * The following code shows how to iterate through them.
 */
function printUnsampledReports(results) {
  if (results && !results.error) {
    var reports = results.items;
    for (var i = 0, report; report = reports[i]; i++) {
      console.log('Account Id: ' + report.accountId);
      console.log('Property Id: ' + report.webPropertyId);
      console.log('Report Id: ' + report.id);
      console.log('Report Title: ' + report.title);
      console.log('Report Kind: ' + report.kind);
      console.log('Report start-date:' + report.start-date);
      console.log('Report end-date:' + report.end-date);
      console.log('Report metrics: ' + report.metrics);
      console.log('Report dimensions:' + report.dimensions);
      console.log('Report filters: ' + report.filters);
      console.log('Report Status: ' + report.status);
      console.log('Report downloadType: ' + report.downloadType);

      // Drive document details.
      if (report.driveDownloadDetails) {
        var details = report.driveDownloadDetails;
        console.log('Drive doc id: ' + details.documentId);
      }

      // Cloud storage download details.
      if (report.cloudStorageDownloadDetails) {
        var details = report.cloudStorageDownloadDetails;
        console.log('Cloud bucket id: ' + details.bucketId);
        console.log('Cloud object id: ' + details.objectId);
      }

      console.log('Report Created: ' + report.created);
      console.log('Report Updated: ' + report.updated);
    }
  }
}