Wypróbuj serwer MCP w Google Analytics. Zainstaluj go z
GitHub. Więcej informacji znajdziesz w
ogłoszeniu.
REST Resource: properties.calculatedMetrics
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Zasób: ComputedMetric
Definicja obliczonych danych.
Zapis JSON |
{
"name": string,
"description": string,
"displayName": string,
"calculatedMetricId": string,
"metricUnit": enum (MetricUnit ),
"restrictedMetricType": [
enum (RestrictedMetricType )
],
"formula": string,
"invalidMetricReference": boolean
} |
Pola |
name |
string
Tylko dane wyjściowe. Nazwa zasobu dla tego ComputedMetric. Format: „properties/{identyfikator_usługi}/ComputeMetrics/{ComputeMetricId}”
|
description |
string
Opcjonalnie: Opis tych obliczonych danych. Maksymalna długość 4096 znaków.
|
displayName |
string
Wymagane. Wyświetlana nazwa tych obliczonych danych widoczna w interfejsie Google Analytics. Maks. długość 82 znaków.
|
calculatedMetricId |
string
Tylko dane wyjściowe. Identyfikator, który ma być używany na potrzeby obliczonych danych. W interfejsie jest to tzw. „nazwa interfejsu API”. Jest on używany do odwoływania się do tych obliczonych danych za pomocą zewnętrznych interfejsów API. Na przykład „calcMetric:{ComputeMetricId}”.
|
metricUnit |
enum (MetricUnit )
Wymagane. Typ wartości obliczonych danych.
|
restrictedMetricType[] |
enum (RestrictedMetricType )
Tylko dane wyjściowe. Typy ograniczonych danych zawartych w tym rodzaju danych.
|
formula |
string
Wymagane. Definicja obliczonych danych. Maksymalna liczba unikalnych przywoływanych danych niestandardowych to 5. Formuły obsługują następujące operacje: + (dodawanie), - (odejmowanie), - (ujemne), * (mnożenie), / (dzielenie), () (nawias). Dopuszczalne są wszystkie prawidłowe liczby rzeczywiste, które mieszczą się w postaci liczby Długiej (64-bitowej) lub Podwójnej (64-bitowej liczby zmiennoprzecinkowej). Przykładowa formuła: "(customEvent:parameterName + cartPurchaseQuantity) / 2.0"
|
invalidMetricReference |
boolean
Tylko dane wyjściowe. Jeśli wartość to prawda, te obliczone dane mają nieprawidłowe odwołanie do danych. Wszystko, co korzysta z obliczonych danych z wartością invalidMetricReference o wartości „true” może spowodować błąd, wyświetlenie ostrzeżeń lub nieoczekiwane wyniki.
|
MetricUnit
Możliwe typy przedstawiania wartości obliczonych danych.
Wartości w polu enum |
METRIC_UNIT_UNSPECIFIED |
Brak wartości lub nie określono MetricUnit. |
STANDARD |
Ten wskaźnik używa jednostek domyślnych. |
CURRENCY |
Te dane określają walutę. |
FEET |
Ta wartość to stopy. |
MILES |
Ten rodzaj danych mierzy mile. |
METERS |
Ta wartość to metry. |
KILOMETERS |
Ta wartość to kilometry. |
MILLISECONDS |
Ta wartość jest mierzona w milisekundach. |
SECONDS |
Ta wartość służy do pomiaru sekund. |
MINUTES |
Ta wartość to pomiar minut. |
HOURS |
Ten wskaźnik mierzy godziny. |
RestrictedMetricType
Etykiety oznaczające dane w obliczonych danych używane w połączeniu z rolami użytkownika, które ograniczają dostęp do danych o kosztach lub przychodach.
Wartości w polu enum |
RESTRICTED_METRIC_TYPE_UNSPECIFIED |
Typ nieznany lub nieokreślony. |
COST_DATA |
Dane są podawane w raportach o kosztach. |
REVENUE_DATA |
Dane są podawane w raportach o przychodach. |
Metody |
|
Tworzy obiekt ComputedMetric. |
|
Usuwa z usługi wartość ComputedMetric. |
|
Wyszukaj pojedynczy element ComputedMetric. |
|
Wyświetla listę ComputedMetrics w usłudze. |
|
Aktualizuje wartość ComputedMetric w usłudze. |
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[null,null,["Ostatnia aktualizacja: 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. |"]]