Zero‑Code Data Tracking for Taro Mini‑Programs with Tencent YouShu

This guide explains how Taro developers can instantly enable eight automatic, zero‑code data‑tracking events and custom analytics in WeChat mini‑programs by integrating Tencent YouShu via a one‑click template, CLI commands, and SDK configuration.

Aotu Lab
Aotu Lab
Aotu Lab
Zero‑Code Data Tracking for Taro Mini‑Programs with Tencent YouShu

Zero‑Code Data Tracking Overview

Taro integrates Tencent YouShu’s invisible data‑tracking capabilities, providing eight automatic events—app launch, show, hide, page view, page leave, share, pull‑down refresh, and reach‑bottom—plus custom events such as search and product attribution. This enables full‑scene analytics for business, live‑stream, and guide‑sale scenarios within the WeChat mini‑program ecosystem.

One‑Click Installation for Zero‑Development Tracking

Run taro init myApp to create a new project.

Select the default-youshu template.

Execute npm run dev:weapp to start the development server.

Open the WeChat Mini‑Program DevTools console to see the eight behavior logs.

Request YouShu data‑view permissions at https://docs.qq.com/form/fill/DUkZHalR0RUJCVkVj#/fill and replace the provided token and appid to activate the production version.

Full‑Domain Analytics

After integration, the YouShu platform displays traffic metrics, channel sources, user trends, audience portraits, and live‑stream data, supporting data‑driven decisions. Advanced capabilities such as product analysis, precise marketing, and audience recommendation are available on request.

Integrating the YouShu SDK into Existing Mini‑Programs

1. Install the SDK

Run npm i sr-sdk-wxapp to add the SDK.

Import it in app.jsx with import sr from 'sr-sdk-wxapp'.

2. Add Trusted Domain

In the WeChat Public Platform ( https://mp.weixin.qq.com/) navigate to Development → Development Settings → Server Domain and add https://zhls.qq.com as a request‑allowed domain.

During development the SDK may warn that https://sr-home-1257214331.cos.ap-guangzhou.myqcloud.com is not in the allowed domain list; this can be bypassed by disabling domain verification.

3. Initialize the SDK

Call sr.init(options) before App(). The options object includes required fields appid and token, plus optional flags.

appid (string, required): WeChat Mini‑Program AppID.

token (string, required): Credential string provided after YouShu access approval.

usePlugin (bool, optional, default false): Whether a Mini‑Program plugin is used.

debug (bool, optional, default false): Enable debug logging.

openSdkShareDepth (bool, optional, default false): Track share chain A→B→C→D.

serverUrl (string, optional, default https://zhls.qq.com/api/report): Custom reporting endpoint; if set, token is ignored.

trackApp (bool, optional, default true): Automatically track app exposure events.

proxyPage (bool, optional, default false): Enable automatic Page proxy for browse/leave/share events.

autoStart (bool, optional, default false): Auto‑start reporting; open_id must be set manually after login.

4. Example Initialization

import sr from 'sr-sdk-wxapp';
sr.init({
  token: 'bi72fccc7184ef4xxx',
  appid: 'wx195745e8e342bxxx',
  usePlugin: false,
  debug: true,
  proxyPage: true,
  proxyComponent: true,
  openSdkShareDepth: true,
  autoTrack: true,
});

Reference Links

SDK documentation for Taro:

https://mp.zhls.qq.com/youshu-docs/develop/sdk/Taro.html?from=taro

Joint Taro‑YouShu guide: https://taro-docs.jd.com/taro/docs/youshu Permission request form:

https://docs.qq.com/form/fill/DUkZHalR0RUJCVkVj#/fill
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

SDKAnalyticsData TrackingTaroWeChat Mini-ProgramZero-Development
Aotu Lab
Written by

Aotu Lab

Aotu Lab, founded in October 2015, is a front-end engineering team serving multi-platform products. The articles in this public account are intended to share and discuss technology, reflecting only the personal views of Aotu Lab members and not the official stance of JD.com Technology.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.