Skip to main content

Auto-tracking

Last updated 08/27/2026

We provide auto-tracking. Enable the events you want to auto-track in the config you use to create the instance, and the SDK automatically collects certain mini program behaviors. The following events currently support auto-tracking:

The auto-collected data currently supported includes:

  1. Mini program initialization, triggered only once per use
  2. Mini program launch, including launching and returning from the background to the foreground
  3. The mini program goes to the background, and the duration of this visit (from launch to going to the background) is recorded

The following sections describe how each type of data is collected

1. Enable auto-tracked events​

In config, each element of the autoTrack parameter is the switch for one auto-tracked event. Set it to true to enable auto-tracking:

var config = {
appid: "YOU-APP-ID",
server_url: "https://youserverurl.com",
autoTrack: {
appLaunch: true, // Auto-track ta_mp_launch
appShow: true, // Auto-track ta_mp_show
appHide: true, // Auto-track ta_mp_hide
appInstall: true,//Auto-track the install event (native only)
appCrash: true, // Auto-track the crash event (native only)
}
};
  • appLaunch: Auto-tracks mini program initialization
  • appShow: Auto-tracks the mini program being launched or entering the foreground from the background
  • appHide: Auto-tracks the mini program going from the foreground to the background
  • appInstall: Auto-tracks the install event (native only)
  • appCrash: Auto-tracks the crash event (native only)

2. Auto-tracked events in detail​

2.1 Mini program initialization​

Mini program initialization is triggered when the mini program is opened for the first time, or when the user kills the process and opens it again. It is triggered only once during the lifecycle of the process. Event details:

  • Event name: ta_mp_launch
  • Auto-tracked properties:
    • #scene: the scene value, taken from the scene values provided by WeChat

With the mini program initialization event, you can calculate the number of uses per day and the average number of uses per user, and group by scene value to view how users from different scene values use the mini program.

2.2 Mini program launch​

Mini program launch is triggered when the mini program is launched or brought back from the background to the foreground. Event details:

  • Event name: ta_mp_show

  • Auto-tracked properties:

    • #scene: the scene value, taken from the scene values provided by WeChat
    • #url_path: the page path, that is, the path of the page displayed when the mini program is launched

Because mini program launch is affected by switching between the foreground and background (which produces many records), it is not well suited for direct analysis. However, it can mark one use by the user in a behavior path and serve as the initial behavior of the user's behavior path

2.3 Mini program hide​

Mini program hide is triggered when the mini program goes to the background, and it records the duration of this use. Event details:

  • Event name: ta_mp_hide

  • Auto-tracked properties:

    • #scene: the scene value, taken from the scene values provided by WeChat
    • #duration: numeric, the duration from this launch (ta_mp_show) to the hide

The mini program hide event records the usage duration (in seconds), so you can directly calculate users' total usage duration and the average duration per user, or divide it by the number of initializations to calculate the duration of a single use.

Was this page helpful?