Custom Metrics: patch

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

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

الطلب

طلب HTTP

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

المَعلمات

اسم المعلَمة القيمة الوصف
مَعلمات المسار
accountId string رقم تعريف الحساب للمقياس المخصّص المطلوب تعديله
customMetricId string رقم تعريف المقياس المخصّص المطلوب تعديله
webPropertyId string رقم تعريف الموقع الإلكتروني للمقياس المخصّص المطلوب تعديله.
مَعلمات طلب البحث الاختيارية

التفويض

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

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

نص الطلب

في نص الطلب، أدخِل الأجزاء ذات الصلة من management.customMetric، وفقًا لقواعد دلالات التصحيح.

الإجابة

في حال نجاحها، تعرض هذه الطريقة موردmanagement.customMetric في نص الاستجابة.

أمثلة

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

Java

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

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

/*
 * This request patches 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()
      .patch("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.

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

# This request patches an existing custom metric.
try:
  analytics.management().customMetrics().patch(
      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))

تجربة

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