On this page
Mini-program analytics needs Pro or above. WeChat, Alipay and Douyin share one SDK with a different entry point each, and one project can show them side by side.
What's recorded automatically
After initialisation, with no extra code:
- Cold starts and every return to the foreground
- Page enter and leave, with time on page
- Shares
- Favourites
Taps are not recorded by default, to keep package size and performance in check. Switch on mini-program autocapture in the console if you need them, or record events on key buttons yourself.
Steps
1. Register the appid
Add the appid under Mini-program analytics › Configuration › SDK code. It must match the one in the platform's admin console exactly.
2. Add the request domain
Add the collection domain shown in the wizard to the mini program's request domain allow list in that platform's admin console.
This is the step people miss. With "don't verify domains" ticked in the developer tools everything works; on a real device or a trial build nothing arrives. That's almost always the reason. After saving the domain, rebuild and upload again — older preview packages keep failing.
3. Install and initialise
Pick the platform in the wizard and copy the install command and initialisation code. Initialisation has two steps here too: pre-initialise at the very top of app.js, which hooks app and page lifecycles automatically; if users must accept a privacy agreement first, finish initialising after they accept.
If your framework can't patch the global Page (some cross-platform frameworks can't), automatic hooking won't work and you wrap each page definition with the SDK's page wrapper instead. The wizard shows how.
4. Preview once
Open the home page in the developer tools or on a device, then check Mini-program analytics › Real-time. A launch event means you're connected.
Connecting users after sign-in
Once you have the user's OpenID (or your own user ID), call the login method with the OpenID type. With identity mode on, the same person's mini-program and website activity can then be merged — see Connecting anonymous visitors to signed-in users.
Scene values
The channels page in mini-program reports can switch to scene values, showing whether people arrived from a QR code, a shared card, search or an official-account article. The platform supplies the scene value and the SDK attaches it.
Offline and weak networks
Events are stored locally and sent when the connection returns. The local queue holds up to 10,000 events, for 7 days, up to about 1 MB; beyond that the oldest are dropped. Normal use rarely gets close.
Excluding test devices
Exclude them under Mini-program analytics › Configuration › Mini-program settings. Without their own rules, mini programs follow the website's exclusion and session rules.