# analysis.getMonthlyRetain
Call this API at the server side. For more information, see Server API.
This API supports Cloud Calls. The WeChat DevTools version must be
1.02.1904090
or later (download the latest stable version here), and thewx-server-sdk
version must be0.4.0
or later.
Obtains the monthly retention of user visits to a Mini Program.
Calling methods:
# HTTPS Call
# Request Address
POST https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyretaininfo?access_token=ACCESS_TOKEN
# Request Parameters
Attribute | Type | Default | Required | Description |
---|---|---|---|---|
access_token | string | Yes | Credentials to call API | |
begin_date | string | Yes | Start date. It is the first day of the natural month, in the format of yyyymmdd. | |
end_date | string | Yes | End date, in the format of yyyymmdd. It is the last day of the natural month. Only the data of one month can be queried. |
# Return Value
# Object
JSON data package that is returned
Attribute | Type | Description |
---|---|---|
ref_date | string | Time, for example, "201702" |
visit_uv_new | Object | Retention of new users |
visit_uv | Object | Retention of active users |
visit_uv_new is composed as follows
Property | Type | Description |
---|---|---|
key | number | The identifier. Its value starts from "0", which indicates the current month, and the value "1" indicates one month later, and so on. Its values include "0" and "1". |
value | number | The number of new or active users (when key is "0") or the number of retained users (when key is greater than "0") on the date corresponding to key. |
visit_uv is composed as follows
Property | Type | Description |
---|---|---|
key | number | The identifier. Its value starts from "0", which indicates the current month, and the value "1" indicates one month later, and so on. Its values include "0" and "1". |
value | number | The number of new or active users (when key is "0") or the number of retained users (when key is greater than "0") on the date corresponding to key. |
# Notes
The properties of the request JSON data packet and the returned JSON data packet are the same as those for the getDailyVisitTrend API. Here, only the data of one natural month can be queried, and the time must be entered according to the natural month, for example, 20170201 (beginning of month) and 20170228 (end of month).
# Request Data Example
{
"begin_date" : "20170201",
"end_date" : "20170228"
}
# Return Data Example
{
"ref_date": "201702",
"visit_uv_new": [
{
"key": 0,
"value": 346249
}
],
"visit_uv": [
{
"key": 0,
"value": 346249
}
]
}
# Cloud Call
Cloud call is a capability provided by Mini Program·Cloud Base that allows you to call WeChat APIs in a cloud function. It must be used via
wx-server-sdk
in the cloud function.
# API Calling Method
openapi.analysis.getMonthlyRetain
You need to configure the permissions for the
analysis.getMonthlyRetain
API viaconfig.json
. Details
# Request Parameters
Attribute | Type | Default | Required | Description |
---|---|---|---|---|
beginDate | string | Yes | Start date. It is the first day of the natural month, in the format of yyyymmdd. | |
endDate | string | Yes | End date, in the format of yyyymmdd. It is the last day of the natural month. Only the data of one month can be queried. |
# Return Value
# Object
JSON data package that is returned
Attribute | Type | Description |
---|---|---|
refDate | string | Time, for example, "201702" |
visitUvNew | Object | Retention of new users |
visitUv | Object | Retention of active users |
visitUvNew is composed as follows
Property | Type | Description |
---|---|---|
key | number | The identifier. Its value starts from "0", which indicates the current month, and the value "1" indicates one month later, and so on. Its values include "0" and "1". |
value | number | The number of new or active users (when key is "0") or the number of retained users (when key is greater than "0") on the date corresponding to key. |
visitUv is composed as follows
Property | Type | Description |
---|---|---|
key | number | The identifier. Its value starts from "0", which indicates the current month, and the value "1" indicates one month later, and so on. Its values include "0" and "1". |
value | number | The number of new or active users (when key is "0") or the number of retained users (when key is greater than "0") on the date corresponding to key. |
# Request Data Example
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'
})
console.log(result)
return result
} catch (err) {
console.log(err)
return err
}
}
# Return Data Example
{
"refDate": "201702",
"visitUvNew": [
{
"key": 0,
"value": 346249
}
],
"visitUv": [
{
"key": 0,
"value": 346249
}
],
"errMsg": "openapi.analysis.getMonthlyRetain:ok"
}