Custom Metrics: list

يجب تقديم تفويض.

يسرد المقاييس المخصّصة التي يمكن للمستخدم الوصول إليها. جرِّبه الآن أو اطّلِع على مثال.

الطلب

طلب HTTP

GET https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/customMetrics

المَعلمات

اسم المعلَمة القيمة الوصف
مَعلمات المسار
accountId string رقم تعريف الحساب للمقاييس المخصّصة المطلوب استردادها.
webPropertyId string رقم تعريف الموقع الإلكتروني للمقاييس المخصّصة المطلوب استردادها.
مَعلمات طلب البحث الاختيارية
max-results integer الحدّ الأقصى لعدد المقاييس المخصّصة المطلوب تضمينها في هذه الإجابة.
start-index integer فهرس الكيان الأول المطلوب استرداده. يمكنك استخدام هذه المَعلمة كآلية تقسيم على صفحات إلى جانب المَعلمة max-results.

التفويض

يتطلب هذا الطلب تفويضًا باستخدام نطاق واحد على الأقل من النطاقات التالية (مزيد من المعلومات عن المصادقة والترخيص).

النطاق
https://www.googleapis.com/auth/analytics.readonly
https://www.googleapis.com/auth/analytics

نص الطلب

لا توفِّر نص طلب بهذه الطريقة.

الإجابة

إذا نجحت هذه الطريقة، ستعرض هذه الطريقة نص استجابة بالبنية التالية:

{
  "kind": "analytics#customMetrics",
  "username": string,
  "totalResults": integer,
  "startIndex": integer,
  "itemsPerPage": integer,
  "previousLink": string,
  "nextLink": string,
  "items": [
    management.customMetrics Resource
  ]
}
اسم الموقع القيمة الوصف Notes
kind string نوع المجموعة
username string رقم تعريف البريد الإلكتروني للمستخدم الذي تمت المصادقة عليه
totalResults integer إجمالي عدد النتائج لطلب البحث، بغض النظر عن عدد النتائج في الرد.
startIndex integer هو فهرس البدء للموارد، والذي يكون 1 تلقائيًا، أو يتم تحديده بطريقة أخرى من خلال مَعلمة طلب البحث لفهرس البدء.
itemsPerPage integer الحد الأقصى لعدد الموارد التي يمكن أن يحتوي عليها الرد، بغض النظر عن العدد الفعلي للموارد المعروضة. تتراوح قيمتها من 1 إلى 1000 مع قيمة تبلغ 1000 تلقائيًا، أو يتم تحديدها من خلال مَعلمة طلب البحث max-results.
items[] list مجموعة من المقاييس المخصّصة

أمثلة

ملاحظة: إنّ الأمثلة المرتبطة بالرموز والمتوفرة لهذه الطريقة لا تمثّل كل لغات البرمجة المتوافقة (يُرجى مراجعة صفحة مكتبات البرامج للاطّلاع على قائمة باللغات المتوافقة).

Java

تستخدم مكتبة عملاء Java.

/**
 * Note: This code assumes you have an authorized Analytics service object.
 */

/**
 * This request lists all custom metrics for the authorized user.
 */
try {
  CustomMetrics metrics = analytics.management.customMetrics
      .list("12345", "UA-12345-1").execute();

} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}


/**
 * The results of the list method are stored in the metrics object.
 * The following code shows how to iterate through them.
 */
for (CustomMetric metric : metrics.getItems()) {
  System.out.println("Metric Kind: " + metric.getKind());
  System.out.println("Metric Id: " + metric.getId());
  System.out.println("Account ID: " + metric.getAccountId());
  System.out.println("Property ID: " + metric.getWebPropertyId());
  System.out.println("Metric Name: " + metric.getName());
  System.out.println("Metric Index: " + metric.getIndex());
  System.out.println("Metric Scope: " + metric.getScope());
  System.out.println("Metric Active: " + metric.getActive());
  System.out.println("Metric Type: " + metric.getType());
  System.out.println("Metric Created: " + metric.getCreated());
  System.out.println("Metric Updated: " + metric.getUpdated());
}

Python

تستخدم مكتبة برامج Python.

# Note: This code assumes you have an authorized Analytics service object.

# This request lists all custom metrics for the authorized user.
try:
  metrics = analytics.management().customMetrics().list(
      accountId='123456',
      webPropertyId='UA-123456-1',
  ).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))


# The results of the list method are stored in the metrics object.
# The following code shows how to iterate through them.
for metric in metrics.get('items', []):
  print 'Metric Kind = %s' % metric.get('kind')
  print 'Metric Id = %s' % metric.get('id')
  print 'Account ID = %s' % metric.get('accountId')
  print 'Property ID = %s' % metric.get('webPropertyId')
  print 'Metric Name = %s' % metric.get('name')
  print 'Metric Index = %s' % metric.get('index')
  print 'Metric Scope = %s' % metric.get('scope')
  print 'Metric Active = %s' % metric.get('active')
  print 'Metric Type = %s' % metric.get('type')
  print 'Metric Created = %s' % metric.get('created')
  print 'Metric Updated = %s' % metric.get('updated')

تجربة

استخدِم مستكشف واجهات برمجة التطبيقات أدناه لطلب هذه الطريقة على البيانات المباشرة والاطّلاع على الردّ. ويمكنك بدلاً من ذلك تجربة المستكشف المستقل.