analysis.getVisitPage

本接口应在服务器端调用,详细说明参见服务端API

本接口支持云调用。需开发者工具版本 >= 1.02.1904090(最新稳定版下载),wx-server-sdk >= 0.4.0

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

调用方式:

HTTPS 调用

请求地址

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

请求参数

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

返回值

Object

返回的 JSON 数据包

属性 类型 说明
page_path string 页面路径
page_visit_pv number 访问次数
page_visit_uv number 访问人数
page_staytime_pv number 次均停留时长
entrypage_pv number 进入页次数
exitpage_pv number 退出页次数
page_share_pv number 转发次数
page_share_uv number 转发人数

请求数据示例

{
  "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 的权限,详情

请求参数

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

返回值

Object

返回的 JSON 数据包

属性 类型 说明
pagePath string 页面路径
pageVisitPv number 访问次数
pageVisitUv number 访问人数
pageStaytimePv number 次均停留时长
entrypagePv number 进入页次数
exitpagePv number 退出页次数
pageSharePv number 转发次数
pageShareUv number 转发人数

请求数据示例

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'
      })
    console.log(result)
    return result
  } catch (err) {
    console.log(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"
}