Yetkilendirme gerektirir
Mevcut bir özel metriği günceller. Hemen deneyin veya bir örneğe göz atın.
İstek
HTTP isteği
PUT https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/customMetrics/customMetricId
Parametreler
Parametre adı | Değer | Açıklama |
---|---|---|
Yol parametreleri | ||
accountId |
string |
Güncellenecek özel metriğin hesap kimliği. |
customMetricId |
string |
Güncellenecek özel metriğin özel metrik kimliği. |
webPropertyId |
string |
Güncellenecek özel metriğin web mülkü kimliği. |
İsteğe bağlı sorgu parametreleri | ||
ignoreCustomDataSourceLinks |
boolean |
Güncellemeyi zorunlu kılın ve bir özel veri kaynağına / veri kümesine bağlanan özel metrikle ilgili tüm uyarıları yoksayın.
(Varsayılan: false )
|
Yetkilendirme
Bu istek, aşağıdaki kapsamla yetkilendirme gerektirir (kimlik doğrulama ve yetkilendirme hakkında daha fazla bilgi edinin).
Kapsam |
---|
https://www.googleapis.com/auth/analytics.edit |
İstek içeriği
İstek gövdesinde bir management.customMetrik kaynağı sağlayın.
Yanıt
Başarılı olursa bu yöntem, yanıt gövdesinde bir management.customMetric kaynağı döndürür.
Ö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 updates an existing custom metric. */ // Construct the body of the request and set its properties. CustomMetric body = new CustomMetric(); body.setName("Level Completions"); body.setScope("HIT"); body.setType("INTEGER"); body.setActive(true); try { analytics.management().customMetrics() .update("123456", "UA-123456-1", "ga:metric2", body).execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); }
Python
Python istemci kitaplığı'nı kullanır.
# Note: This code assumes you have an authorized Analytics service object. # This request updates an existing custom metric. try: analytics.management().customMetrics().update( accountId='123456', webPropertyId='UA-123456-1', customMetricId='ga:metric2', body={ 'name': 'Level Completions', 'scope': 'HIT', 'type': 'INTEGER', 'active': True } ).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))
Deneyin.
Aşağıdaki API Gezgini'ni kullanarak canlı verilerde bu yöntemi çağırın ve yanıtı görün. Alternatif olarak, bağımsız Gezgin'i deneyin.