REST Resource: properties.calculatedMetrics

資源:CalculatedMetric

計算指標的定義。

JSON 表示法
{
  "name": string,
  "description": string,
  "displayName": string,
  "calculatedMetricId": string,
  "metricUnit": enum (MetricUnit),
  "restrictedMetricType": [
    enum (RestrictedMetricType)
  ],
  "formula": string,
  "invalidMetricReference": boolean
}
欄位
name

string

ID。這個 CalculatedMetric 的資源名稱。格式:「properties/{property_id}/calculatedMetrics/{calculatedMetricId}」

description

string

(選用步驟) 這項計算指標的說明。長度上限為 4,096 個字元。

displayName

string

必填。這個計算指標在 Google Analytics 使用者介面中顯示的名稱。長度上限為 82 個半形字元。

calculatedMetricId

string

僅供輸出。計算指標要使用的 ID。在使用者介面中,這項配額稱為「API 名稱」。

從外部 API 參照這項計算指標時,會使用 calculatedMetricId。例如「calcMetric:{calculatedMetricId}」。

metricUnit

enum (MetricUnit)

必填。計算指標值的類型。

restrictedMetricType[]

enum (RestrictedMetricType)

僅供輸出。這項指標包含的受限資料類型。

formula

string

必填。計算指標的定義。最多只能參照 5 個不重複的自訂指標。公式支援下列運算:+ (加法)、- (減法)、- (負數)、* (乘法)、/ (除法)、() (括號)。只要是符合 Long (64 位元整數) 或 Double (64 位元浮點數) 的有效實數,都可以接受。公式範例:「( customEvent:parameterName + cartPurchaseQuantity ) / 2.0」

invalidMetricReference

boolean

僅供輸出。如果為 true,表示這項計算指標的指標參照無效。如果使用計算指標,且 invalidMetricReference 設為 true,可能會失敗、產生警告或產生非預期的結果。

MetricUnit

可能代表計算指標值的類型。

列舉
METRIC_UNIT_UNSPECIFIED 未指定或缺少 MetricUnit。
STANDARD 這項指標使用預設單位。
CURRENCY 這項指標會評估貨幣。
FEET 這項指標的單位為英尺。
MILES 這項指標會測量里程數。
METERS 這項指標會測量公尺。
KILOMETERS 這項指標以公里為單位。
MILLISECONDS 這項指標的測量單位為毫秒。
SECONDS 這項指標的測量單位為秒。
MINUTES 這項指標以分鐘為單位。
HOURS 這項指標以小時為單位。

RestrictedMetricType

標籤會標示計算指標中的資料,並搭配使用者角色使用,限制費用和/或收益指標的存取權。

列舉
RESTRICTED_METRIC_TYPE_UNSPECIFIED 類型不明或未指定。
COST_DATA 指標報表會提供費用資料。
REVENUE_DATA 指標報表會顯示收益資料。

方法

create

建立 CalculatedMetric。

delete

刪除資源中的 CalculatedMetric。

get

查詢單一 CalculatedMetric。

list

列出資源的 CalculatedMetrics。

patch

更新資源的 CalculatedMetric。