Reference documentation and code samples for the Google Analytics Admin V1alpha Client class CalculatedMetric.
A definition for a calculated metric.
Generated from protobuf messagegoogle.analytics.admin.v1alpha.CalculatedMetric
Namespace
Google \ Analytics \ Admin \ V1alpha
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ name
string
Output only. Resource name for this CalculatedMetric. Format: 'properties/{property_id}/calculatedMetrics/{calculated_metric_id}'
↳ description
string
Optional. Description for this calculated metric. Max length of 4096 characters.
↳ display_name
string
Required. Display name for this calculated metric as shown in the Google Analytics UI. Max length 82 characters.
↳ calculated_metric_id
string
Output only. The ID to use for the calculated metric. In the UI, this is referred to as the "API name." The calculated_metric_id is used when referencing this calculated metric from external APIs. For example, "calcMetric:{calculated_metric_id}".
↳ metric_unit
int
Required. The type for the calculated metric's value.
↳ restricted_metric_type
array
Output only. Types of restricted data that this metric contains.
↳ 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:parameter_name + cartPurchaseQuantity ) / 2.0"
↳ invalid_metric_reference
bool
Output only. If true, this calculated metric has a invalid metric reference. Anything using a calculated metric with invalid_metric_reference set to true may fail, produce warnings, or produce unexpected results.
getName
Output only. Resource name for this CalculatedMetric.
Required. Display name for this calculated metric as shown in the
Google Analytics UI. Max length 82 characters.
Returns
Type
Description
string
setDisplayName
Required. Display name for this calculated metric as shown in the
Google Analytics UI. Max length 82 characters.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getCalculatedMetricId
Output only. The ID to use for the calculated metric. In the UI, this is
referred to as the "API name."
The calculated_metric_id is used when referencing this calculated metric
from external APIs. For example, "calcMetric:{calculated_metric_id}".
Returns
Type
Description
string
setCalculatedMetricId
Output only. The ID to use for the calculated metric. In the UI, this is
referred to as the "API name."
The calculated_metric_id is used when referencing this calculated metric
from external APIs. For example, "calcMetric:{calculated_metric_id}".
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getMetricUnit
Required. The type for the calculated metric's value.
Returns
Type
Description
int
setMetricUnit
Required. The type for the calculated metric's value.
Parameter
Name
Description
var
int
Returns
Type
Description
$this
getRestrictedMetricType
Output only. Types of restricted data that this metric contains.
Output only. Types of restricted data that this metric contains.
Parameter
Name
Description
var
int[]
Returns
Type
Description
$this
getFormula
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:parameter_name + cartPurchaseQuantity ) / 2.0"
Returns
Type
Description
string
setFormula
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:parameter_name + cartPurchaseQuantity ) / 2.0"
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getInvalidMetricReference
Output only. If true, this calculated metric has a invalid metric
reference. Anything using a calculated metric with invalid_metric_reference
set to true may fail, produce warnings, or produce unexpected results.
Returns
Type
Description
bool
setInvalidMetricReference
Output only. If true, this calculated metric has a invalid metric
reference. Anything using a calculated metric with invalid_metric_reference
set to true may fail, produce warnings, or produce unexpected results.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Analytics Admin V1alpha Client - Class CalculatedMetric (0.29.1)\n\nVersion latestkeyboard_arrow_down\n\n- [0.29.1 (latest)](/php/docs/reference/analytics-admin/latest/V1alpha.CalculatedMetric)\n- [0.29.0](/php/docs/reference/analytics-admin/0.29.0/V1alpha.CalculatedMetric)\n- [0.28.1](/php/docs/reference/analytics-admin/0.28.1/V1alpha.CalculatedMetric)\n- [0.27.0](/php/docs/reference/analytics-admin/0.27.0/V1alpha.CalculatedMetric)\n- [0.26.0](/php/docs/reference/analytics-admin/0.26.0/V1alpha.CalculatedMetric)\n- [0.25.2](/php/docs/reference/analytics-admin/0.25.2/V1alpha.CalculatedMetric)\n- [0.24.2](/php/docs/reference/analytics-admin/0.24.2/V1alpha.CalculatedMetric)\n- [0.23.0](/php/docs/reference/analytics-admin/0.23.0/V1alpha.CalculatedMetric)\n- [0.22.5](/php/docs/reference/analytics-admin/0.22.5/V1alpha.CalculatedMetric)\n- [0.20.0](/php/docs/reference/analytics-admin/0.20.0/V1alpha.CalculatedMetric)\n- [0.19.0](/php/docs/reference/analytics-admin/0.19.0/V1alpha.CalculatedMetric)\n- [0.18.1](/php/docs/reference/analytics-admin/0.18.1/V1alpha.CalculatedMetric)\n- [0.17.0](/php/docs/reference/analytics-admin/0.17.0/V1alpha.CalculatedMetric)\n- [0.16.0](/php/docs/reference/analytics-admin/0.16.0/V1alpha.CalculatedMetric)\n- [0.15.1](/php/docs/reference/analytics-admin/0.15.1/V1alpha.CalculatedMetric)\n- [0.14.0](/php/docs/reference/analytics-admin/0.14.0/V1alpha.CalculatedMetric)\n- [0.13.0](/php/docs/reference/analytics-admin/0.13.0/V1alpha.CalculatedMetric)\n- [0.12.0](/php/docs/reference/analytics-admin/0.12.0/V1alpha.CalculatedMetric)\n- [0.11.1](/php/docs/reference/analytics-admin/0.11.1/V1alpha.CalculatedMetric)\n- [0.10.0](/php/docs/reference/analytics-admin/0.10.0/V1alpha.CalculatedMetric)\n- [0.9.0](/php/docs/reference/analytics-admin/0.9.0/V1alpha.CalculatedMetric)\n- [0.8.2](/php/docs/reference/analytics-admin/0.8.2/V1alpha.CalculatedMetric) \n| **Beta**\n|\n|\n| This library is covered by the [Pre-GA Offerings Terms](/terms/service-terms#1)\n| of the Terms of Service. Pre-GA libraries might have limited support,\n| and changes to pre-GA libraries might not be compatible with other pre-GA versions.\n| For more information, see the\n[launch stage descriptions](/products#product-launch-stages). \nReference documentation and code samples for the Google Analytics Admin V1alpha Client class CalculatedMetric.\n\nA definition for a calculated metric.\n\nGenerated from protobuf message `google.analytics.admin.v1alpha.CalculatedMetric`\n\nNamespace\n---------\n\nGoogle \\\\ Analytics \\\\ Admin \\\\ V1alpha\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getName\n\nOutput only. Resource name for this CalculatedMetric.\n\nFormat: 'properties/{property_id}/calculatedMetrics/{calculated_metric_id}'\n\n### setName\n\nOutput only. Resource name for this CalculatedMetric.\n\nFormat: 'properties/{property_id}/calculatedMetrics/{calculated_metric_id}'\n\n### getDescription\n\nOptional. Description for this calculated metric.\n\nMax length of 4096 characters.\n\n### setDescription\n\nOptional. Description for this calculated metric.\n\nMax length of 4096 characters.\n\n### getDisplayName\n\nRequired. Display name for this calculated metric as shown in the\nGoogle Analytics UI. Max length 82 characters.\n\n### setDisplayName\n\nRequired. Display name for this calculated metric as shown in the\nGoogle Analytics UI. Max length 82 characters.\n\n### getCalculatedMetricId\n\nOutput only. The ID to use for the calculated metric. In the UI, this is\nreferred to as the \"API name.\"\nThe calculated_metric_id is used when referencing this calculated metric\nfrom external APIs. For example, \"calcMetric:{calculated_metric_id}\".\n\n### setCalculatedMetricId\n\nOutput only. The ID to use for the calculated metric. In the UI, this is\nreferred to as the \"API name.\"\nThe calculated_metric_id is used when referencing this calculated metric\nfrom external APIs. For example, \"calcMetric:{calculated_metric_id}\".\n\n### getMetricUnit\n\nRequired. The type for the calculated metric's value.\n\n### setMetricUnit\n\nRequired. The type for the calculated metric's value.\n\n### getRestrictedMetricType\n\nOutput only. Types of restricted data that this metric contains.\n\n### setRestrictedMetricType\n\nOutput only. Types of restricted data that this metric contains.\n\n### getFormula\n\nRequired. The calculated metric's definition. Maximum number of unique\nreferenced custom metrics is 5. Formulas supports the following operations:\n\n- (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).\n\nExample formula:\n\"( customEvent:parameter_name + cartPurchaseQuantity ) / 2.0\"\n\n### setFormula\n\nRequired. The calculated metric's definition. Maximum number of unique\nreferenced custom metrics is 5. Formulas supports the following operations:\n\n- (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).\n\nExample formula:\n\"( customEvent:parameter_name + cartPurchaseQuantity ) / 2.0\"\n\n### getInvalidMetricReference\n\nOutput only. If true, this calculated metric has a invalid metric\nreference. Anything using a calculated metric with invalid_metric_reference\nset to true may fail, produce warnings, or produce unexpected results.\n\n### setInvalidMetricReference\n\nOutput only. If true, this calculated metric has a invalid metric\nreference. Anything using a calculated metric with invalid_metric_reference\nset to true may fail, produce warnings, or produce unexpected results."]]