通过 Google Analytics API 和 GA Web UI 获取的数据不匹配

Mismatch between data fetched through the Google Analytics API and the GA Web UI

我创建了以下查询以从 GA 中获取事件数据:

request_body = {
            'reportRequests': [
                {
                    'viewId': 'xxxxx', 
                    'dateRanges': [{'startDate': '2020-01-01', 'endDate': '2020-03-31'}],
                    'metrics': [
                        {'expression': 'ga:itemRevenue'},
                        {'expression': 'ga:sessionDuration'},
                        ],
                    # Get Pages
                    'dimensions': [
                        {"name": "ga:clientId"},
                        {"name": "ga:pagePath"},
                        {"name": "ga:dateHourMinute"},
                        {"name": "ga:shoppingStage"},
                        {"name": "ga:eventAction"},
                        {"name": "ga:source"},
                        ],
                    # Filter by condition "containing products"
                    'orderBys': [{"fieldName": "ga:dateHourMinute", "sortOrder": "ASCENDING"}],
                    'pageSize': 1000,
                }]
    }

我总共收集了 13.683 行:

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 13683 entries, 0 to 13682
Data columns (total 8 columns):
 #   Column           Non-Null Count  Dtype 
---  ------           --------------  ----- 
 0   clientId         13683 non-null  object
 1   pagePath         13683 non-null  object
 2   dateHourMinute   13683 non-null  object
 3   shoppingStage    13683 non-null  object
 4   eventAction      13683 non-null  object
 5   source           13683 non-null  object
 6   itemRevenue      13683 non-null  object
 7   sessionDuration  13683 non-null  object
dtypes: object(8)
memory usage: 855.3+ KB

我在 GA 网络界面中查看了同一时间段的购物行为分析(因为我查询了 ga:shoppingStage

以及事件概览(因为我查询了ga:eventAction

我希望在事件中看到类似的数字,但看不到任何匹配项。我做错了什么?

购物行为分析显示会话,而事件是单一交互。在单个会话中,用户可以进行多个交互(多个事件)。

在任何情况下,您都在比较具有混合范围(用户、会话、命中)的不可比较报告。