# analysis.getDailyRetain

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 the wx-server-sdk version must be 0.4.0 or later.

Obtains the daily retention of user visits to a Mini Program.

Calling methods:

# HTTPS Call

# Request Address

POST https://api.weixin.qq.com/datacube/getweanalysisappiddailyretaininfo?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, in the format of yyyymmdd.
end_date string Yes End date, in the format of yyyymmdd. Only the data of one day can be queried, and the maximum value is the previous day.

# Return Value

# Object

JSON data package that is returned

Attribute Type Description
ref_date string Date
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 day, and the value "1" indicates one day later, and so on. Its values include "0", "1", "2", "3", "4", "5", "6","7", "14", and "30".
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 day, and the value "1" indicates one day later, and so on. Its values include "0", "1", "2", "3", "4", "5", "6","7", "14", and "30".
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

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

# Return Data Example

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

# 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.getDailyRetain

You need to configure the permissions for the analysis.getDailyRetain API via config.json. Details

# Request Parameters

Attribute Type Default Required Description
beginDate string Yes Start date, in the format of yyyymmdd.
endDate string Yes End date, in the format of yyyymmdd. Only the data of one day can be queried, and the maximum value is the previous day.

# Return Value

# Object

JSON data package that is returned

Attribute Type Description
refDate string Date
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 day, and the value "1" indicates one day later, and so on. Its values include "0", "1", "2", "3", "4", "5", "6","7", "14", and "30".
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 day, and the value "1" indicates one day later, and so on. Its values include "0", "1", "2", "3", "4", "5", "6","7", "14", and "30".
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.getDailyRetain({
        beginDate: '20170313',
        endDate: '20170313'
      })
      console.log(result)
      return result
    } catch (err) {
      console.log(err)
      return err
    }
  }

# Return Data Example

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