Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program access retention


May 19, 2021 WeChat Mini Program Development Document


Table of contents


analysis.getDailyRetain

This interface should be called on the server side, see Service API
This interface support Cloud call .Need Developer Tools> = 1.02.1904090 (Latest Stable version download
wx-server-sdk >= 0.4.0

Get user access to small program days

Call mode:

  • HTTPS call
  • Cloud call

HTTPS call

Request address

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

Request parameters

Attributes type Defaults Required illustrate
access_token string Yes Interface call credential
begin_date string Yes start date.Format YYYYMMDD
end_date string Yes At the end date, the query is limited to 1 day data, allowing the maximum value to be set to yesterday.Format YYYYMMDD

return value

Object

Returned JSON packet

Attributes type illustrate
ref_date string date
visit_uv_new Object Add user retention
visit_uv Object Active user keeps

Visit_uv_new structure

Attributes type illustrate
key number The logo, 0 starts, indicates that day, 1 indicates 1 day.According to this type, the KEY value is: 0, 1, 2, 3, 4, 5, 6, 7, 14, 30
value number KEY's number of new users of the corresponding date (when Key = 0) or the number of retained users (k> 0)

Visit_UV structure

Attributes type illustrate
key number The logo, 0 starts, indicates that day, 1 indicates 1 day.According to this type, the KEY value is: 0, 1, 2, 3, 4, 5, 6, 7, 14, 30
value number KEY's number of new users of the corresponding date (when Key = 0) or the number of retained users (k> 0)

Request data example

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

Return an example of the data

{
  "ref_date": "20170313",
  "visit_uv_new": [
    {
      "key": 0,
      "value": 5464
    }
  ],
  "visit_uv": [
    {
      "key": 0,
      "value": 55500
    }
  ]
}

Cloud calls

Cloud call is the ability provided by the small program Cloud Development to call WeChat open interfaces in cloud functions and need to be used in cloud functions via wx-server-sdk.

The interface method

openapi.analysis.getDailyRetain
The permissions for the analysis.getDailyRetain API need to be configured in config.json, details

Request parameters

Property Type The default Required Description
beginDate string Is The start date. The format is yyyymmdd
endDate string Is End date, limit queries to 1 day of data, allow setting the maximum value for yesterday. The format is yyyymmdd

Returns a value

Object

The returned JSON packet

Property Type Description
refDate string Date
visitUvNew Object New user retention
visitUv Object Active users are retained

The structure of visitUvNew

Property Type Description
key number Identification, 0 starts, indicates the day, 1 means 1 day later. And so on, key values are: 0, 1, 2, 3, 4, 5, 6, 7, 14, 30
value number Number of new/active users for key corresponding dates (key-0) or number of retained users (k>0)

The structure of visitUv

Property Type Description
key number Identification, 0 starts, indicates the day, 1 means 1 day later. And so on, key values are: 0, 1, 2, 3, 4, 5, 6, 7, 14, 30
value number Number of new/active users for key corresponding dates (key-0) or number of retained users (k>0)

An example of requesting data

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

Return an example of the data

{
  "refDate": "20170313",
  "visitUvNew": [
    {
      "key": 0,
      "value": 5464
    }
  ],
  "visitUv": [
    {
      "key": 0,
      "value": 55500
    }
  ],
  "errMsg": "openapi.analysis.getDailyRetain:ok"
}

analysis.getMonthlyRetain

This interface should be called on the server side, as detailed in the Service Side API.
This interface supports cloud calls. Developer tool version required . . . 1.02.1904090 (latest stable download)
wx-server-sdk >= 0.4.0

Gets the monthly retention of the user access gadget

How to call:

  • HTTPS call
  • Cloud calls

HTTPS call

The request address

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

Request parameters

Property Type The default Required Description
access_token string Is The interface calls the credentials
begin_date string Is The start date, which is the first day of the natural month. The format is yyyymmdd
end_date string Is The end date, the last day of the natural month, limits the query to one month of data. The format is yyyymmdd

Returns a value

Object

The returned JSON packet

Property Type Description
ref_date string Time, e.g. "201702"
visit_uv_new Object New user retention
visit_uv Object Active users are retained

visit_uv_new structure of the system

Property Type Description
key number Identification, 0 starts, represents the month, 1 means after Jan. Key values are: 0, 1
value number Number of new/active users for key corresponding dates (key-0) or number of retained users (k>0)

visit_uv structure of the system

Property Type Description
key number Identification, 0 starts, represents the month, 1 means after Jan. Key values are: 0, 1
value number Number of new/active users for key corresponding dates (key-0) or number of retained users (k>0)

Attention

Request jason and return jason consistent with the day, here limit query data for a natural month, time must be entered in the way of natural month: e.g. 20170201 (early month), 20170228 (month end)

An example of requesting data

{
  "begin_date" : "20170201",
  "end_date" : "20170228"
}

Return an example of the data

{
  "ref_date": "201702",
  "visit_uv_new": [
    {
      "key": 0,
      "value": 346249
    }
  ],
  "visit_uv": [
    {
      "key": 0,
      "value": 346249
    }
  ]
}

Cloud calls

Cloud call is the ability provided by the small program Cloud Development to call WeChat open interfaces in cloud functions and need to be used in cloud functions via wx-server-sdk.

The interface method

openapi.analysis.getMonthlyRetain
The permissions for the analysis.getMonthlyRetain API need to be configured in config.json, details

Request parameters

Property Type The default Required Description
beginDate string Is The start date, which is the first day of the natural month. The format is yyyymmdd
endDate string Is The end date, the last day of the natural month, limits the query to one month of data. The format is yyyymmdd

Returns a value

Object

The returned JSON packet

Property Type Description
refDate string Time, e.g. "201702"
visitUvNew Object New user retention
visitUv Object Active users are retained

The structure of visitUvNew

Property Type Description
key number Identification, 0 starts, represents the month, 1 means after Jan. Key values are: 0, 1
value number Number of new/active users for key corresponding dates (key-0) or number of retained users (k>0)

The structure of visitUv

Property Type Description
key number Identification, 0 starts, represents the month, 1 means after Jan. Key values are: 0, 1
value number Number of new/active users for key corresponding dates (key-0) or number of retained users (k>0)

An example of requesting data

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

Return an example of the data

{
  "refDate": "201702",
  "visitUvNew": [
    {
      "key": 0,
      "value": 346249
    }
  ],
  "visitUv": [
    {
      "key": 0,
      "value": 346249
    }
  ],
  "errMsg": "openapi.analysis.getMonthlyRetain:ok"
}

analysis.getWeeklyRetain

This interface should be called on the server side, as detailed in the Service Side API.
This interface supports cloud calls. Developer tool version required . . . 1.02.1904090 (latest stable download)
wx-server-sdk >= 0.4.0

Gets the user access to the gadget weekly retention

How to call:

  • HTTPS call
  • Cloud calls

HTTPS call

The request address

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

Request parameters

Property Type The default Required Description
access_token string Is The interface calls the credentials
begin_date string Is The start date, which is Monday. The format is yyyymmdd
end_date string Is The end date, which is Sunday, limits the query to one week's data. The format is yyyymmdd

Returns a value

Object

The returned JSON packet

Property Type Description
ref_date string Time, e.g. "20170306-20170312"
visit_uv_new Object New user retention
visit_uv Object Active users are retained

visit_uv_new structure of the system

Property Type Description
key number Identification, 0 starts, indicates the week, 1 indicates 1 week later. And so on, the values are: 0, 1, 2, 3, 4
value number Number of new/active users for key corresponding dates (key-0) or number of retained users (k>0)

visit_uv structure of the system

Property Type Description
key number Identification, 0 starts, indicates the week, 1 indicates 1 week later. And so on, the values are: 0, 1, 2, 3, 4
value number Number of new/active users for key corresponding dates (key-0) or number of retained users (k>0)

Attention

Request jason and return jason consistent with the day, here limit query data for a natural week, the time must be entered in the nature week way: e.g. 20170306 (Monday), 20170312 (Sunday)

An example of requesting data

{
  "begin_date" : "20170306",
  "end_date" : "20170312"
}

Return an example of the data

{
  "ref_date": "20170306-20170312",
  "visit_uv_new": [
    {
      "key": 0,
      "value": 0
    },
    {
      "key": 1,
      "value": 16853
    }
  ],
  "visit_uv": [
    {
      "key": 0,
      "value": 0
    },
    {
      "key": 1,
      "value": 99310
    }
  ]
}

Cloud calls

Cloud call is the ability provided by the small program Cloud Development to call WeChat open interfaces in cloud functions and need to be used in cloud functions via wx-server-sdk.

The interface method

openapi.analysis.getWeeklyRetain
The permissions for the analysis.getWeeklyRetain API need to be configured in config.json, details

Request parameters

Property Type The default Required Description
beginDate string Is The start date, which is Monday. The format is yyyymmdd
endDate string Is The end date, which is Sunday, limits the query to one week's data. The format is yyyymmdd

Returns a value

Object

The returned JSON packet

Property Type Description
refDate string Time, e.g. "20170306-20170312"
visitUvNew Object New user retention
visitUv Object Active users are retained

The structure of visitUvNew

Property Type Description
key number Identification, 0 starts, indicates the week, 1 indicates 1 week later. And so on, the values are: 0, 1, 2, 3, 4
value number Number of new/active users for key corresponding dates (key-0) or number of retained users (k>0)

The structure of visitUv

Property Type Description
key number Identification, 0 starts, indicates the week, 1 indicates 1 week later. And so on, the values are: 0, 1, 2, 3, 4
value number Number of new/active users for key corresponding dates (key-0) or number of retained users (k>0)

An example of requesting data

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

Return an example of the data

{
  "refDate": "20170306-20170312",
  "visitUvNew": [
    {
      "key": 0,
      "value": 0
    },
    {
      "key": 1,
      "value": 16853
    }
  ],
  "visitUv": [
    {
      "key": 0,
      "value": 0
    },
    {
      "key": 1,
      "value": 99310
    }
  ],
  "errMsg": "openapi.analysis.getWeeklyRetain:ok"
}