微信小程序 getVisitDistribution

2022-05-10 16:23 更新

analysis.getVisitDistribution

本接口應在服務器端調(diào)用,詳細說明參見服務端API。
本接口支持云調(diào)用。需開發(fā)者工具版本 >= 1.02.1904090(最新穩(wěn)定版下載
wx-server-sdk >= 0.4.0

獲取用戶小程序訪問分布數(shù)據(jù)

調(diào)用方式:

  • HTTPS 調(diào)用
  • 云調(diào)用

HTTPS 調(diào)用

請求地址

POST https://api.weixin.qq.com/datacube/getweanalysisappidvisitdistribution?access_token=ACCESS_TOKEN

請求參數(shù)

屬性 類型 默認值 必填 說明
access_token string 接口調(diào)用憑證
begin_date string 開始日期。格式為 yyyymmdd
end_date string 結(jié)束日期,限定查詢 1 天數(shù)據(jù),允許設置的最大值為昨日。格式為 yyyymmdd

返回值

Object

返回的 JSON 數(shù)據(jù)包

屬性 類型 說明
ref_date string 日期,格式為 yyyymmdd
list Array.<Object> 數(shù)據(jù)列表

list 的結(jié)構(gòu)

屬性 類型 說明
index number 分布類型
item_list Array.<Object> 分布數(shù)據(jù)列表

index 的合法值

說明 最低版本
access_source_session_cnt 訪問來源分布
access_staytime_info 訪問時長分布
access_depth_info 訪問深度的分布

item_list 的結(jié)構(gòu)

屬性 類型 說明
key number 場景 id,定義在各個 index 下不同,具體參見下方表格
value number 該場景 id 訪問 pv
access_source_visit_uv number 該場景 id 訪問 uv

請求數(shù)據(jù)示例

{
  "begin_date" : "20170313",
  "end_date" : "20170313"
}

返回數(shù)據(jù)示例

{
  "ref_date": "20170313",
  "list": [
    {
      "index": "access_source_session_cnt",
      "item_list": [
        {
          "key": 10,
          "value": 5
        },
        {
          "key": 8,
          "value": 687
        },
        {
          "key": 7,
          "value": 10740
        },
        {
          "key": 6,
          "value": 1961
        },
        {
          "key": 5,
          "value": 677
        },
        {
          "key": 4,
          "value": 653
        },
        {
          "key": 3,
          "value": 1120
        },
        {
          "key": 2,
          "value": 10243
        },
        {
          "key": 1,
          "value": 116578
        }
      ]
    },
    {
      "index": "access_staytime_info",
      "item_list": [
        {
          "key": 8,
          "value": 16329
        },
        {
          "key": 7,
          "value": 19322
        },
        {
          "key": 6,
          "value": 21832
        },
        {
          "key": 5,
          "value": 19539
        },
        {
          "key": 4,
          "value": 29670
        },
        {
          "key": 3,
          "value": 19667
        },
        {
          "key": 2,
          "value": 11794
        },
        {
          "key": 1,
          "value": 4511
        }
      ]
    },
    {
      "index": "access_depth_info",
      "item_list": [
        {
          "key": 5,
          "value": 217
        },
        {
          "key": 4,
          "value": 3259
        },
        {
          "key": 3,
          "value": 32445
        },
        {
          "key": 2,
          "value": 63542
        },
        {
          "key": 1,
          "value": 43201
        }
      ]
    }
  ]
}

訪問來源 key 對應關系(index="access_source_session_cnt"),場景值說明參見 場景值

key 訪問來源 對應場景值
1 小程序歷史列表 1001 1002 1004
2 搜索 1005 1006 1027 1042 1053 1106 1108 1132
3 會話 1007 1008 1044 1093 1094 1096
4 掃一掃二維碼 1011 1025 1047 1105 1124 1150
5 公眾號主頁 1020
6 聊天頂部 1022
7 系統(tǒng)桌面 1023 1113 1114 1117
8 小程序主頁 1024 1135
9 附近的小程序 1026 1033 1068
11 模板消息 1014 1043 1107 1162
12 客服消息 1021
13 公眾號菜單 1035 1102 1130
14 APP分享 1036
15 支付完成頁 1034 1060 1072 1097 1109 1137 1149
16 長按識別二維碼 1012 1048 1050 1125
17 相冊選取二維碼 1013 1049 1126
18 公眾號文章 1058 1091
19 錢包 1019 1057 1061 1066 1070 1071
20 卡包 1028 1128 1148
21 小程序內(nèi)卡券 1029 1062
22 其他小程序 1037
23 其他小程序返回 1038
24 卡券適用門店列表 1052
25 搜索框快捷入口 1054
26 小程序客服消息 1073 1081
27 公眾號下發(fā) 1074 1076 1082 1152
28 系統(tǒng)會話菜單 1080 1083 1088
29 任務欄-最近使用 1089
30 長按小程序菜單圓點 1085 1090 1147
31 連wifi成功頁 1064 1078
32 城市服務 1092
33 微信廣告 1045 1046 1067 1084 1095
34 其他移動應用 1065 1069 1111 1140
35 發(fā)現(xiàn)入口-我的小程序 1003 1103
36 任務欄-我的小程序 1104
37 微信圈子 1138 1163
38 手機充值 1098
39 H5 1018 1055
40 插件 1040 1041 1099
41 大家在用 1118 1145
42 發(fā)現(xiàn)頁 1112 1141 1142 1143
43 浮窗 1131
44 附近的人 1075 1134
45 看一看 1115
46 朋友圈 1009 1110 1154 1155
47 企業(yè)微信 1119 1120 1121 1122 1123 1156
48 視頻 1136 1144
49 收藏 1010
50 微信紅包 1100
51 微信游戲中心 1079 1127
52 搖一搖 1039 1077
53 公眾號導購消息 1157
54 識物 1153
55 小程序訂單 1151
56 小程序直播 1161
57 群工具 1158 1159 1160
10 其他 除上述外其余場景值

訪問時長 key 對應關系(index="access_staytime_info")

key 訪問時長
1 0-2s
2 3-5s
3 6-10s
4 11-20s
5 20-30s
6 30-50s
7 50-100s
8 >100s

平均訪問深度 key 對應關系(index="access_depth_info")

key 訪問時長
1 1 頁
2 2 頁
3 3 頁
4 4 頁
5 5 頁
6 6-10 頁
7 >10 頁

云調(diào)用

云調(diào)用是小程序·云開發(fā)提供的在云函數(shù)中調(diào)用微信開放接口的能力,需要在云函數(shù)中通過 wx-server-sdk 使用。

接口方法

openapi.analysis.getVisitDistribution
需在 config.json 中配置 analysis.getVisitDistribution API 的權(quán)限,詳情

請求參數(shù)

屬性 類型 默認值 必填 說明
beginDate string 開始日期。格式為 yyyymmdd
endDate string 結(jié)束日期,限定查詢 1 天數(shù)據(jù),允許設置的最大值為昨日。格式為 yyyymmdd

返回值

Object

返回的 JSON 數(shù)據(jù)包

屬性 類型 說明
refDate string 日期,格式為 yyyymmdd
list Array.<Object> 數(shù)據(jù)列表

list 的結(jié)構(gòu)

屬性 類型 說明
index number 分布類型
itemList Array.<Object> 分布數(shù)據(jù)列表

index 的合法值

說明 最低版本
access_source_session_cnt 訪問來源分布
access_staytime_info 訪問時長分布
access_depth_info 訪問深度的分布

itemList 的結(jié)構(gòu)

屬性 類型 說明
key number 場景 id,定義在各個 index 下不同,具體參見下方表格
value number 該場景 id 訪問 pv
accessSourceVisitUv number 該場景 id 訪問 uv

請求數(shù)據(jù)示例

const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi.analysis.getVisitDistribution({
        beginDate: '20170313',
        endDate: '20170313'
      })
    return result
  } catch (err) {
    return err
  }
}

返回數(shù)據(jù)示例

{
  "refDate": "20170313",
  "list": [
    {
      "index": "access_source_session_cnt",
      "itemList": [
        {
          "key": 10,
          "value": 5
        },
        {
          "key": 8,
          "value": 687
        },
        {
          "key": 7,
          "value": 10740
        },
        {
          "key": 6,
          "value": 1961
        },
        {
          "key": 5,
          "value": 677
        },
        {
          "key": 4,
          "value": 653
        },
        {
          "key": 3,
          "value": 1120
        },
        {
          "key": 2,
          "value": 10243
        },
        {
          "key": 1,
          "value": 116578
        }
      ]
    },
    {
      "index": "access_staytime_info",
      "itemList": [
        {
          "key": 8,
          "value": 16329
        },
        {
          "key": 7,
          "value": 19322
        },
        {
          "key": 6,
          "value": 21832
        },
        {
          "key": 5,
          "value": 19539
        },
        {
          "key": 4,
          "value": 29670
        },
        {
          "key": 3,
          "value": 19667
        },
        {
          "key": 2,
          "value": 11794
        },
        {
          "key": 1,
          "value": 4511
        }
      ]
    },
    {
      "index": "access_depth_info",
      "itemList": [
        {
          "key": 5,
          "value": 217
        },
        {
          "key": 4,
          "value": 3259
        },
        {
          "key": 3,
          "value": 32445
        },
        {
          "key": 2,
          "value": 63542
        },
        {
          "key": 1,
          "value": 43201
        }
      ]
    }
  ],
  "errMsg": "openapi.analysis.getVisitDistribution:ok"
}


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號