簡體   English   中英

Google Analytics User-ID 報告維度和指標

[英]Google Analytics User-ID report Dimensions and Metrics

我需要用每個用戶的 User-ID 報告數據填充我的數據庫(我所指的報告可以在 Google Analytics > Reports > User Explorer (> click on the user id) 中找到)。

我正在查看文檔,但似乎找不到可用於完成此操作的任何維度或指標: https : //ga-dev-tools.appspot.com/dimensions-metrics-explorer/?authuser=1

我希望我有一些代碼示例,但是替代方法是運行此腳本(為簡單起見,我不會在此處包含所有其他功能)

def get_user_Activity(analytics, VIEW_ID, user_id, start_date, end_date):
    # Use the Analytics Service Object to query the Analytics Reporting API V4.
    return analytics.userActivity().search(
        body={
            "viewId": VIEW_ID,
            "user": {
                "type": "USER_ID",
                "userId": user_id
            },
            "dateRange": {
                "startDate": start_date,
                "endDate": end_date
            },
            "activityTypes": [
                "PAGEVIEW", "EVENT"
            ]
        }
    ).execute()

這將為每個用戶 ID 生成此字典:

{'sessions': [{'sessionId': '1579xxxx', 
               'deviceCategory': 'desktop', 
               'platform': 'Windows', 
               'dataSource': 'web', 
               'activiti es': [{'activityTime': '2020-01-22T12:48:20.971410Z', 
                               source': '(direct)', 
                              'medium': '(none)', 
                              'channelGrouping': 'Direct', 
                              'campaign': '(not set)', 
                              'keyword': '(not set)', 
                              'hostname': 'example.com', 
                              'landingPagePath': '/somelandingpage', 
                              'activityType': 'PAGEVIEW', 
                              'customDimension': [{'index': 1}], 
                              'pageview': {'pagePath': '/some/page', 'pageTitle': 'SOME Title'}}, 
                             {'activityTime': '2020-01-22T12:48:20.970754Z', 
                              'source': '(direct)', 
                              'medium': '(none)', 
                              'channelGrouping': 'Direct', 
                              'campaign': '(not set)', 
                              'keyword': '(not set)', 
                              'hostname': 'example.com',
                              'landingPagePath': '/somelandingpage', 
                              'activityType': 'PAGEVIEW', 
                              'customDimension': [{'index': 1}], 
                              'pageview': {'pagePath': '/some/other/path', 'pageTitle': 'SomeTitle'}},...
                              ..................
                              etc ..............

這種方法的麻煩在於我必須去計算我感興趣的大部分指標,相反,我更願意只收集指標並填充數據庫。

如果可以提供所需的“ga:dimension(s)”和“ga:metric(s)”,將不勝感激。

Google Core Reporting API 中沒有對 userId 級別報告的內置支持,因此您必須根據 Activity API 響應中的可用內容計算所有必要的指標。 唯一的替代方法是擁有與用戶 ID 具有相同值的用戶級自定義維度。 但是,這僅在您提前實施此跟蹤時才有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM