Skip to main content

Mini Program Integration

We support redirecting to the WeSurvey Mini Program from within other mini programs, supporting half-screen mini program display, and automatically returning to the original mini program after users submit the survey.

Configuration Steps

1. Determine the survey sid and hash values

If the survey link is https://wesurvey.com/s2/123456789/abcd/, the sid is 123456789 and the hash is abcd.

2. Apply for half-screen mini program permission in WeChat Mini Program Admin Console

Log in to the WeChat Public Platform Admin Console at https://mp.weixin.qq.com/

Add WeSurvey in [Settings - Third-party Settings - Half-screen Mini Program Management - My Calls], with AppID wxebadf544ddae62cb. WeSurvey will be automatically approved.

3. Configure in mini program code

wx.openEmbeddedMiniProgram({
appId: 'wxebadf544ddae62cb',
path: 'pages/webview/index?sid=123456789&hash=abcd&navigateBackMiniProgram=true',
});

Note: Replace the sid and hash in the path with the values obtained in step 1

Supported Parameters

queryDescription
sidSurvey ID
hashSurvey hash
Custom parameters (userid, from...)Must add custom parameters first, View documentation
navigateBackMiniProgramWhether to automatically return to original mini program after submission

Return Parameters (extraData)

The survey mini program will return some status information to the redirecting mini program, which can be obtained in App.onShow. See WeChat official documentation

Example:

{
"scene":1038,
"referrerInfo":{
"appId":"wxebadf544ddae62cb",
"extraData":{
"status":"answered",
"answer_hash": "dZG8pVyMEX",
}
}
}

status of answered indicates the survey has been submitted answer_hash is the record of the submitted survey response

The extraData is only included when the response is completed normally and either automatically returns to the original mini program or when clicking the "Return to Previous Mini Program" button.

Important Notes

  1. If half-screen mini program is not needed, you can use regular mini program redirection by skipping step 2 of the above configuration steps and calling wx.navigateToMiniProgram. All other steps remain the same.
  2. Half-screen mini program is supported from base library version 2.20.1. For versions below 2.23.1, you need to configure embeddedAppIdList in app.json. See https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/openEmbeddedMiniProgram.html