Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
273 views
in Technique[技术] by (71.8m points)

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

I created following query to fetch event data from 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,
                }]
    }

I collected 13.683 rows in total:

<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

I looked in the GA web interface into the Shopping Behavior Analysis (because I queried ga:shoppingStage) for the same time period (Q1/CY2020)

enter image description here

as well as the events overview (because I queried ga:eventAction) enter image description here

I expected to see similar numbers in the events but can't see any match. What am I doing wrong?

question from:https://stackoverflow.com/questions/65891476/mismatch-between-data-fetched-through-the-google-analytics-api-and-the-ga-web-ui

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Shopping Behavior Analysis show sessions while events are single interactions. In a single session a user can have multiple interactions (multiple events).

In any case, you are comparing non-comparable reports with mixed scope (user, session, hit).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...