Hãy thử máy chủ MCP cho Google Analytics. Cài đặt từ
GitHub và xem
thông báo để biết thêm thông tin chi tiết.
REST Resource: properties.calculatedMetrics
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tài nguyên: BillingMetric
Định nghĩa cho một chỉ số được tính toán.
Biểu diễn dưới dạng JSON |
{
"name": string,
"description": string,
"displayName": string,
"calculatedMetricId": string,
"metricUnit": enum (MetricUnit ),
"restrictedMetricType": [
enum (RestrictedMetricType )
],
"formula": string,
"invalidMetricReference": boolean
} |
Trường |
name |
string
Chỉ có đầu ra. Tên tài nguyên của PaymentMetric này. Định dạng: 'properties/{property_id}/cộtMetrics/{CalculateMetricId}'
|
description |
string
Không bắt buộc. Nội dung mô tả cho chỉ số được tính này. Độ dài tối đa là 4.096 ký tự.
|
displayName |
string
Bắt buộc. Tên hiển thị cho chỉ số được tính này như xuất hiện trong giao diện người dùng Google Analytics. Độ dài tối đa 82 ký tự.
|
calculatedMetricId |
string
Chỉ có đầu ra. Mã nhận dạng cần sử dụng cho chỉ số được tính toán. Trong giao diện người dùng, tên này được gọi là "tên API". Hệ thống sử dụng BillingMetricId khi tham chiếu chỉ số được tính toán này từ các API bên ngoài. Ví dụ: "calcMetric:{MetricMetricId}".
|
metricUnit |
enum (MetricUnit )
Bắt buộc. Loại cho giá trị của chỉ số được tính toán.
|
restrictedMetricType[] |
enum (RestrictedMetricType )
Chỉ có đầu ra. Các loại dữ liệu bị hạn chế có trong chỉ số này.
|
formula |
string
Bắt buộc. Định nghĩa của chỉ số được tính toán. Số lượng tối đa các chỉ số tuỳ chỉnh được tham chiếu duy nhất là 5. Công thức hỗ trợ các phép toán sau: + (cộng), - (trừ), - (âm), * (nhân), / (chia), () (dấu ngoặc đơn). Mọi số thực hợp lệ đều có thể phù hợp với dạng Long (số nguyên 64 bit) hoặc Kép (số thực 64 bit có dấu phẩy động). Công thức mẫu: "(customEvent:parameterName + cartPurchaseQuantity ) / 2.0"
|
invalidMetricReference |
boolean
Chỉ có đầu ra. Nếu đúng, chỉ số được tính này có một tệp tham chiếu chỉ số không hợp lệ. Bất cứ thao tác nào sử dụng chỉ số được tính toán có validMetricReference được đặt thành true đều có thể không thành công, tạo cảnh báo hoặc tạo ra kết quả không mong muốn.
|
MetricUnit
Các loại có thể biểu thị giá trị của chỉ số được tính toán.
Enum |
METRIC_UNIT_UNSPECIFIED |
Đơn vị chỉ số không được chỉ định hoặc bị thiếu. |
STANDARD |
Chỉ số này sử dụng các đơn vị mặc định. |
CURRENCY |
Chỉ số này đo lường một đơn vị tiền tệ. |
FEET |
Chỉ số này đo lường bộ. |
MILES |
Chỉ số này đo lường dặm. |
METERS |
Chỉ số này đo lường số mét. |
KILOMETERS |
Chỉ số này đo lường số kilômét. |
MILLISECONDS |
Chỉ số này đo lường bằng mili giây. |
SECONDS |
Chỉ số này đo lường số giây. |
MINUTES |
Chỉ số này đo lường số phút. |
HOURS |
Chỉ số này đo lường giờ. |
RestrictedMetricType
Các nhãn đánh dấu dữ liệu trong chỉ số được tính toán được dùng cùng với vai trò của người dùng nhằm hạn chế quyền truy cập vào các chỉ số về chi phí và/hoặc doanh thu.
Enum |
RESTRICTED_METRIC_TYPE_UNSPECIFIED |
Loại không xác định hoặc chưa được chỉ định. |
COST_DATA |
Chỉ số báo cáo dữ liệu chi phí. |
REVENUE_DATA |
Chỉ số báo cáo dữ liệu doanh thu. |
Phương thức |
|
Tạo chỉ số được tính. |
|
Xoá BillingMetric trên một tài sản. |
|
Tìm một PaymentMetric duy nhất. |
|
Liệt kê ManagedMetrics trên một thuộc tính. |
|
Cập nhật PaymentMetric trên một tài sản. |
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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. |"]]