微信小程序开发文档 微信小程序 getVisitPage

2024-02-25 开发教程 微信小程序开发文档 匿名 3

analysis.getVisitPage

本接口应在服务器端调用,详细说明参见服务端API。 本接口支持云调用。需开发者工具版本 >= 1.02.1904090(最新稳定版下载
wx-server-sdk >= 0.4.0

访问页面。目前只提供按 page_visit_pv 排序的 top200。

调用方式:

  • HTTPS 调用
  • 云调用

HTTPS 调用

请求地址

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

请求参数

属性类型默认值必填说明
access_tokenstring接口调用凭证
begin_datestring开始日期。格式为 yyyymmdd
end_datestring结束日期,限定查询1天数据,允许设置的最大值为昨日。格式为 yyyymmdd

返回值

Object

返回的 JSON 数据包

属性类型说明
page_pathstring页面路径
page_visit_pvnumber访问次数
page_visit_uvnumber访问人数
page_staytime_pvnumber次均停留时长
entrypage_pvnumber进入页次数
exitpage_pvnumber退出页次数
page_share_pvnumber转发次数
page_share_uvnumber转发人数

请求数据示例

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

返回数据示例

{
"ref_date": "20170313",
"list": [
{
"page_path": "pages/main/main.html",
"page_visit_pv": 213429,
"page_visit_uv": 55423,
"page_staytime_pv": 8.139198,
"entrypage_pv": 117922,
"exitpage_pv": 61304,
"page_share_pv": 180,
"page_share_uv": 166
},
{
"page_path": "pages/linedetail/linedetail.html",
"page_visit_pv": 155030,
"page_visit_uv": 42195,
"page_staytime_pv": 35.462395,
"entrypage_pv": 21101,
"exitpage_pv": 47051,
"page_share_pv": 47,
"page_share_uv": 42
},
{
"page_path": "pages/search/search.html",
"page_visit_pv": 65011,
"page_visit_uv": 24716,
"page_staytime_pv": 6.889634,
"entrypage_pv": 1811,
"exitpage_pv": 3198,
"page_share_pv": 0,
"page_share_uv": 0
},
{
"page_path": "pages/stationdetail/stationdetail.html",
"page_visit_pv": 29953,
"page_visit_uv": 9695,
"page_staytime_pv": 7.558508,
"entrypage_pv": 1386,
"exitpage_pv": 2285,
"page_share_pv": 0,
"page_share_uv": 0
},
{
"page_path": "pages/switch-city/switch-city.html",
"page_visit_pv": 8928,
"page_visit_uv": 4017,
"page_staytime_pv": 9.22659,
"entrypage_pv": 748,
"exitpage_pv": 1613,
"page_share_pv": 0,
"page_share_uv": 0
}
]
}

云调用

云调用是小程序·云开发提供的在云函数中调用微信开放接口的能力,需要在云函数中通过 wx-server-sdk 使用。

接口方法

openapi.analysis.getVisitPage

需在 config.json 中配置 analysis.getVisitPage API 的权限,详情

请求参数

属性类型默认值必填说明
beginDatestring开始日期。格式为 yyyymmdd
endDatestring结束日期,限定查询1天数据,允许设置的最大值为昨日。格式为 yyyymmdd

返回值

Object

返回的 JSON 数据包

属性类型说明
pagePathstring页面路径
pageVisitPvnumber访问次数
pageVisitUvnumber访问人数
pageStaytimePvnumber次均停留时长
entrypagePvnumber进入页次数
exitpagePvnumber退出页次数
pageSharePvnumber转发次数
pageShareUvnumber转发人数

请求数据示例

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

返回数据示例

{
"refDate": "20170313",
"list": [
{
"pagePath": "pages/main/main.html",
"pageVisitPv": 213429,
"pageVisitUv": 55423,
"pageStaytimePv": 8.139198,
"entrypagePv": 117922,
"exitpagePv": 61304,
"pageSharePv": 180,
"pageShareUv": 166
},
{
"pagePath": "pages/linedetail/linedetail.html",
"pageVisitPv": 155030,
"pageVisitUv": 42195,
"pageStaytimePv": 35.462395,
"entrypagePv": 21101,
"exitpagePv": 47051,
"pageSharePv": 47,
"pageShareUv": 42
},
{
"pagePath": "pages/search/search.html",
"pageVisitPv": 65011,
"pageVisitUv": 24716,
"pageStaytimePv": 6.889634,
"entrypagePv": 1811,
"exitpagePv": 3198,
"pageSharePv": 0,
"pageShareUv": 0
},
{
"pagePath": "pages/stationdetail/stationdetail.html",
"pageVisitPv": 29953,
"pageVisitUv": 9695,
"pageStaytimePv": 7.558508,
"entrypagePv": 1386,
"exitpagePv": 2285,
"pageSharePv": 0,
"pageShareUv": 0
},
{
"pagePath": "pages/switch-city/switch-city.html",
"pageVisitPv": 8928,
"pageVisitUv": 4017,
"pageStaytimePv": 9.22659,
"entrypagePv": 748,
"exitpagePv": 1613,
"pageSharePv": 0,
"pageShareUv": 0
}
],
"errMsg": "openapi.analysis.getVisitPage:ok"
}