Google Analytics API文檔顯示,爲獲取生命週期值,不應指定日期範圍。但是,當我提出這樣的請求(沒有日期範圍)時,它會返回空的維度和度量結果。但是,當我使用日期範圍時,它會返回該日期範圍的維度和指標值。從Google Analytics API獲取生命週期價值
下面是從API documentation的摘錄:
日期範圍應當不爲羣組或壽命值 請求來指定。
例如,如果我讓沒有日期範圍內的請求,如下所示:
{
"reportRequests": [
{
"viewId": "XXXXXXXXX",
"dimensions": [
{
"name": "ga:date"
},
{
"name": "ga:eventLabel"
}
],
"metrics": [
{
"expression": "ga:totalEvents"
}
]
}
]
}
我得到以下響應:
{
"reports": [
{
"columnHeader": {
"dimensions": [
"ga:date",
"ga:eventLabel"
],
"metricHeader": {
"metricHeaderEntries": [
{
"name": "ga:totalEvents",
"type": "INTEGER"
}
]
}
},
"data": {
"totals": [
{
"values": [
"0"
]
}
]
}
}
]
}
然而,如果我包括的時間範圍,
{
"reportRequests": [
{
"viewId": "XXXXXXXX",
"dimensions": [
{
"name": "ga:date"
},
{
"name": "ga:eventLabel"
}
],
"metrics": [
{
"expression": "ga:totalEvents"
}
],
"dateRanges": [
{
"startDate": "2016-01-01",
"endDate": "2016-04-30"
}
]
}
]
}
我得到t他以下回應:
{
"reports": [
{
"columnHeader": {
"dimensions": [
"ga:date",
"ga:eventLabel"
],
"metricHeader": {
"metricHeaderEntries": [
{
"name": "ga:totalEvents",
"type": "INTEGER"
}
]
}
},
"data": {
"rows": [
{
"dimensions": [
"20160412",
"http://mytestblog.com/"
],
"metrics": [
{
"values": [
"1"
]
}
]
},
{
"dimensions": [
"20160412",
"http://mytestblog.com/2016/04/first-post.html"
],
"metrics": [
{
"values": [
"3"
]
}
]
},
{
"dimensions": [
"20160419",
"http://mytestblog.com/"
],
"metrics": [
{
"values": [
"4"
]
}
]
},
{
"dimensions": [
"20160419",
"http://mytestblog.com/2016/04/fourth.html"
],
"metrics": [
{
"values": [
"13"
]
}
]
}
],
"totals": [
{
"values": [
"21"
]
}
],
"rowCount": 4,
"minimums": [
{
"values": [
"1"
]
}
],
"maximums": [
{
"values": [
"13"
]
}
]
}
}
]
}
爲什麼說,儘管文件規定,我必須在指定的日期的ReportRequest範圍得到的值?我在這裏誤解了終身價值的含義嗎?
感謝您的評論@馬特。似乎有[Lifetime Value Report](https://support.google.com/analytics/answer/6182550)與CohortGroup分開。本報告僅適用於[應用程序視圖](https://support.google.com/analytics/answer/2649553#WebVersusAppViews)。此外,默認情況下,沒有指定日期範圍,它似乎是爲當前月份獲取數據(至少爲webview) – Kenpachi
爲了澄清,爲了創建一個生命期值請求,您必須定義一個'cohortGroup'並設置'lifetimeValue'字段爲** True **。 – Matt