ลองใช้เซิร์ฟเวอร์ MCP สำหรับ Google Analytics ติดตั้งจาก
GitHub และดูรายละเอียดเพิ่มเติมได้ที่
ประกาศ
REST Resource: properties.calculatedMetrics
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ทรัพยากร: ที่คำนวณเมตริก
คำจำกัดความของเมตริกที่คำนวณแล้ว
การแสดง JSON |
{
"name": string,
"description": string,
"displayName": string,
"calculatedMetricId": string,
"metricUnit": enum (MetricUnit ),
"restrictedMetricType": [
enum (RestrictedMetricType )
],
"formula": string,
"invalidMetricReference": boolean
} |
ช่อง |
name |
string
เอาต์พุตเท่านั้น ชื่อทรัพยากรสำหรับเมตริกที่คำนวณแล้วนี้ รูปแบบ: "properties/{property_id}/collectdMetrics/{datadMetricId}"
|
description |
string
ไม่บังคับ คำอธิบายสำหรับเมตริกที่คำนวณแล้วนี้ มีความยาวสูงสุด 4,096 อักขระ
|
displayName |
string
ต้องระบุ ชื่อที่แสดงของเมตริกที่คำนวณแล้วนี้ตามที่แสดงใน UI ของ Google Analytics ความยาวสูงสุด 82 อักขระ
|
calculatedMetricId |
string
เอาต์พุตเท่านั้น รหัสที่ใช้สำหรับเมตริกที่คำนวณแล้ว โดยใน UI นี้จะเรียกว่า "ชื่อ API" ระบบใช้ dataMetricId เมื่ออ้างอิงเมตริกที่คํานวณนี้จาก API ภายนอก เช่น "calcMetric:{collectdMetricId}"
|
metricUnit |
enum (MetricUnit )
ต้องระบุ ประเภทสำหรับค่าของเมตริกที่คำนวณแล้ว
|
restrictedMetricType[] |
enum (RestrictedMetricType )
เอาต์พุตเท่านั้น ประเภทของข้อมูลที่ถูกจำกัดในเมตริกนี้
|
formula |
string
ต้องระบุ คำจำกัดความของเมตริกที่คำนวณแล้ว จำนวนเมตริกที่กำหนดเองแบบอ้างอิงที่ไม่ซ้ำได้สูงสุด 5 รายการ สูตรรองรับการดำเนินการต่อไปนี้ + (การเพิ่ม), - (การลบ), - (ลบ), * (การคูณ), / (การหาร), () (วงเล็บ) สามารถใส่จำนวนจริงที่ถูกต้องได้ ซึ่งใช้ได้กับจำนวนเต็มแบบยาว (จำนวนเต็ม 64 บิต) หรือเลขคู่ (เลขทศนิยม 64 บิต) สูตรตัวอย่าง: "( customEvent:parameterName + cartPurchaseQuantity ) / 2.0"
|
invalidMetricReference |
boolean
เอาต์พุตเท่านั้น หากจริง เมตริกที่คำนวณแล้วนี้มีการอ้างอิงเมตริกที่ไม่ถูกต้อง ทุกอย่างที่ใช้เมตริกที่คำนวณแล้วซึ่งมีการตั้งค่า invalidMetricReference เป็น "จริง" อาจล้มเหลว สร้างคำเตือน หรือสร้างผลลัพธ์ที่ไม่คาดคิด
|
MetricUnit
ประเภทที่เป็นไปได้ในการแสดงค่าของเมตริกที่คำนวณแล้ว
Enum |
METRIC_UNIT_UNSPECIFIED |
ไม่ได้ระบุหรือไม่มี MetricUnit |
STANDARD |
เมตริกนี้ใช้หน่วยเริ่มต้น |
CURRENCY |
เมตริกนี้จะวัดสกุลเงิน |
FEET |
เมตริกนี้วัดฟุต |
MILES |
เมตริกนี้วัดไมล์ |
METERS |
เมตริกนี้วัดเมตร |
KILOMETERS |
เมตริกนี้วัดกิโลเมตร |
MILLISECONDS |
เมตริกนี้จะวัดมิลลิวินาที |
SECONDS |
เมตริกนี้จะวัดจำนวนวินาที |
MINUTES |
เมตริกนี้จะวัดนาที |
HOURS |
เมตริกนี้วัดชั่วโมง |
RestrictedMetricType
ป้ายกำกับที่ทำเครื่องหมายข้อมูลในเมตริกที่คำนวณแล้วร่วมกับบทบาทของผู้ใช้ที่จำกัดการเข้าถึงเมตริกค่าใช้จ่ายและ/หรือรายได้
Enum |
RESTRICTED_METRIC_TYPE_UNSPECIFIED |
ประเภทที่ไม่รู้จักหรือไม่ได้ระบุ |
COST_DATA |
เมตริกจะรายงานข้อมูลค่าใช้จ่าย |
REVENUE_DATA |
เมตริกจะรายงานข้อมูลรายได้ |
เมธอด |
|
สร้างเมตริกที่คำนวณแล้ว |
|
ลบเมตริกที่คำนวณแล้วในพร็อพเพอร์ตี้ |
|
ค้นหาเมตริกที่คำนวณแล้วรายการเดียว |
|
แสดงรายการเมตริกที่คำนวณแล้วในพร็อพเพอร์ตี้ |
|
อัปเดตเมตริกที่คำนวณแล้วในพร็อพเพอร์ตี้ |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eCalculatedMetric\u003c/code\u003e allows you to create custom metrics using formulas based on existing metrics and parameters, with options for units like currency, time, or distance.\u003c/p\u003e\n"],["\u003cp\u003eYou can define the display name, description, and formula for your custom metric, along with specifying its unit of measurement.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Analytics provides a dedicated resource and API for managing calculated metrics, allowing you to create, update, delete, and list them within your properties.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eCalculatedMetric\u003c/code\u003e resources have fields indicating if they contain cost or revenue data or have invalid metric references.\u003c/p\u003e\n"]]],["Calculated metrics are defined with a name, description, display name, and a unique ID. They also specify a `metricUnit` (e.g., standard, currency, feet) and can contain `restrictedMetricTypes` (cost or revenue data). The `formula` field defines the metric's calculation, supporting basic arithmetic. Methods include creating, deleting, retrieving, listing, and updating calculated metrics. Metrics can reference up to five custom metrics. `invalidMetricReference` flag indicates issues.\n"],null,["# REST Resource: properties.calculatedMetrics\n\n- [Resource: CalculatedMetric](#CalculatedMetric)\n - [JSON representation](#CalculatedMetric.SCHEMA_REPRESENTATION)\n- [MetricUnit](#MetricUnit)\n- [RestrictedMetricType](#RestrictedMetricType)\n- [Methods](#METHODS_SUMMARY)\n\nResource: CalculatedMetric\n--------------------------\n\nA definition for a calculated metric.\n\n| JSON representation |\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"name\": string, \"description\": string, \"displayName\": string, \"calculatedMetricId\": string, \"metricUnit\": enum (/analytics/devguides/config/admin/v1/rest/v1alpha/properties.calculatedMetrics#MetricUnit), \"restrictedMetricType\": [ enum (/analytics/devguides/config/admin/v1/rest/v1alpha/properties.calculatedMetrics#RestrictedMetricType) ], \"formula\": string, \"invalidMetricReference\": boolean } ``` |\n\n| Fields ||\n|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `name` | `string` Output only. Resource name for this CalculatedMetric. Format: 'properties/{property_id}/calculatedMetrics/{calculatedMetricId}' |\n| `description` | `string` Optional. Description for this calculated metric. Max length of 4096 characters. |\n| `displayName` | `string` Required. Display name for this calculated metric as shown in the Google Analytics UI. Max length 82 characters. |\n| `calculatedMetricId` | `string` Output only. The ID to use for the calculated metric. In the UI, this is referred to as the \"API name.\" The calculatedMetricId is used when referencing this calculated metric from external APIs. For example, \"calcMetric:{calculatedMetricId}\". |\n| `metricUnit` | `enum (`[MetricUnit](/analytics/devguides/config/admin/v1/rest/v1alpha/properties.calculatedMetrics#MetricUnit)`)` Required. The type for the calculated metric's value. |\n| `restrictedMetricType[]` | `enum (`[RestrictedMetricType](/analytics/devguides/config/admin/v1/rest/v1alpha/properties.calculatedMetrics#RestrictedMetricType)`)` Output only. Types of restricted data that this metric contains. |\n| `formula` | `string` Required. The calculated metric's definition. Maximum number of unique referenced custom metrics is 5. Formulas supports the following operations: + (addition), - (subtraction), - (negative), \\* (multiplication), / (division), () (parenthesis). Any valid real numbers are acceptable that fit in a Long (64bit integer) or a Double (64 bit floating point number). Example formula: \"( customEvent:parameterName + cartPurchaseQuantity ) / 2.0\" |\n| `invalidMetricReference` | `boolean` Output only. If true, this calculated metric has a invalid metric reference. Anything using a calculated metric with invalidMetricReference set to true may fail, produce warnings, or produce unexpected results. |\n\nMetricUnit\n----------\n\nPossible types of representing the calculated metric's value.\n\n| Enums ||\n|---------------------------|------------------------------------|\n| `METRIC_UNIT_UNSPECIFIED` | MetricUnit unspecified or missing. |\n| `STANDARD` | This metric uses default units. |\n| `CURRENCY` | This metric measures a currency. |\n| `FEET` | This metric measures feet. |\n| `MILES` | This metric measures miles. |\n| `METERS` | This metric measures meters. |\n| `KILOMETERS` | This metric measures kilometers. |\n| `MILLISECONDS` | This metric measures milliseconds. |\n| `SECONDS` | This metric measures seconds. |\n| `MINUTES` | This metric measures minutes. |\n| `HOURS` | This metric measures hours. |\n\nRestrictedMetricType\n--------------------\n\nLabels that mark the data in calculated metric used in conjunction with user roles that restrict access to cost and/or revenue metrics.\n\n| Enums ||\n|--------------------------------------|------------------------------|\n| `RESTRICTED_METRIC_TYPE_UNSPECIFIED` | Type unknown or unspecified. |\n| `COST_DATA` | Metric reports cost data. |\n| `REVENUE_DATA` | Metric reports revenue data. |\n\n| Methods ------- ||\n|-----------------------------------------------------------------------------------------------------|-------------------------------------------|\n| ### [create](/analytics/devguides/config/admin/v1/rest/v1alpha/properties.calculatedMetrics/create) | Creates a CalculatedMetric. |\n| ### [delete](/analytics/devguides/config/admin/v1/rest/v1alpha/properties.calculatedMetrics/delete) | Deletes a CalculatedMetric on a property. |\n| ### [get](/analytics/devguides/config/admin/v1/rest/v1alpha/properties.calculatedMetrics/get) | Lookup for a single CalculatedMetric. |\n| ### [list](/analytics/devguides/config/admin/v1/rest/v1alpha/properties.calculatedMetrics/list) | Lists CalculatedMetrics on a property. |\n| ### [patch](/analytics/devguides/config/admin/v1/rest/v1alpha/properties.calculatedMetrics/patch) | Updates a CalculatedMetric on a property. |"]]