Custom Metrics: list

Yetkilendirme gerektirir

Kullanıcının erişebildiği özel metrikleri listeler. Hemen deneyin veya bir örneğe göz atın.

İstek

HTTP isteği

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

Parametreler

Parametre adı Değer Açıklama
Yol parametreleri
accountId string Alınacak özel metriklerin hesap kimliği.
webPropertyId string Alınacak özel metriklerin web mülkü kimliği.
İsteğe bağlı sorgu parametreleri
max-results integer Bu yanıta dahil edilecek maksimum özel metrik sayısı.
start-index integer Alınacak ilk varlığın dizini. Bu parametreyi, max-results parametresiyle birlikte sayfalara ayırma mekanizması olarak kullanın.

Yetkilendirme

Bu istek için aşağıdaki kapsamlardan en az biriyle yetkilendirme gerekir (kimlik doğrulama ve yetkilendirme hakkında daha fazla bilgi edinin).

Kapsam
https://www.googleapis.com/auth/analytics.readonly
https://www.googleapis.com/auth/analytics

İstek içeriği

Bu yöntemle bir istek gövdesi sağlamayın.

Yanıt

Başarılı olursa bu yöntem aşağıdaki yapıya sahip bir yanıt gövdesi döndürür:

{
  "kind": "analytics#customMetrics",
  "username": string,
  "totalResults": integer,
  "startIndex": integer,
  "itemsPerPage": integer,
  "previousLink": string,
  "nextLink": string,
  "items": [
    management.customMetrics Resource
  ]
}
Mülk adı Değer Açıklama Notlar
kind string Koleksiyon türü.
username string Kimliği doğrulanan kullanıcının e-posta kimliği
totalResults integer Yanıttaki sonuç sayısından bağımsız olarak sorgu için toplam sonuç sayısı.
startIndex integer Kaynakların başlangıç dizini (varsayılan olarak 1'dir veya başlangıç dizini sorgu parametresi tarafından başka şekilde belirtilir).
itemsPerPage integer Döndürülen gerçek kaynak sayısından bağımsız olarak yanıtın içerebileceği maksimum kaynak sayısı. Bu parametrenin değeri, varsayılan olarak 1000 değeriyle 1 ile 1000 arasında değişir veya max-results sorgu parametresiyle belirlenir.
items[] list Özel metrik koleksiyonu.

Örnekler

Not: Bu yöntem için kullanıma sunulan kod örnekleri, desteklenen tüm programlama dillerini kapsamaz (Desteklenen dillerin listesi için istemci kitaplıkları sayfasını inceleyin).

Java

Java istemci kitaplığı'nı kullanmalıdır.

/**
 * 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 istemci kitaplığını kullanır.

# 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')

Deneyin.

Canlı verilerde bu yöntemi çağırmak ve yanıtı görmek için aşağıdaki API Gezgini'ni kullanın. Alternatif olarak, bağımsız Gezgin'i deneyin.