All Products
Search
Document Center

Quick Tracking:Common Scenarios and Tracking Suggestions

Last Updated:May 15, 2025

1 Event sending before page jump

Description

When the user 「clicks the button that will immediately jump the page」 on the page, the triggered click event may not be sent because the page immediately jumps. If you want to ensure that data is sent as much as possible in this scenario, you can delay the page jump. Take the code of the WeChat mini program as an example:

// Click the link.
function targetLinkCLK(url) {
  // Delay page redirection and reserve the amount of time for the SDK to send the page.
  setTimeOut(function(){
    wx.navigateTo({
      url: `/pages/goods/details/index`,
    });
  }, 500);
  const { aplus } =Mini Program Platform Environment Variables // Such as WeChat wx, Alipay my, Byte tt, Baidu Swan, etc.
  aplus.record('track_navigate_clk', 'CLK', { 
    param1: xxxx, 
    param2: xxxx
  });
}

2 Application startup redirects to another page

Description

In some scenarios, the startup page of the mini program is not fixed, and you want to relaunch it to other pages based on some business logic. In this case, the page code and page title of the application startup event may be inconsistent with the mapping in pageConfig. If this scenario exists, you can delay the redirectTo API call. Take the code of the WeChat mini program as an example:

App({
    onLaunch(){
    setTimeout(()=>{
      wx.redirectTo({
        url: 'test?id=1'
      });
    }, 500);
  },
    onShow(){},
    onHide(){}
})

3 How to track WeChat mini program plug-ins

Scenario Description

In some scenarios, WeChat applet developers need to package some independent and reusable pages and components into WeChat applet plug-ins, and then complete the overall application development by integrating WeChat applet plug-ins through WeChat applet main package

3.1 Integration and configuration of the host applet QuickTracking applet SDK

imageimage

3.2 Export SDK environment variables for plug-in calls

Create the exportToPlugin.js file and implement the following logic

image

image

Then export the js file that needs to be exposed to the plug-in in app.json.

image

Example of a page view event:

const aplus = require('../utils/aplus.js');
Page({
  data: {},
  onLoad() {
    console.log('This is a plugin page!', aplus);
  },
  onShow() {
    aplus.sendPV({is_auto: false}, {page_name: 'plugin_page'});
  },
})

Click event example:

const aplus = require('../utils/aplus.js');
Page({
  data: {},
  testCLK() {
    aplus.record('test_plugin_clk', 'CLK', {a: 1, b:2})
  }
})

Note that the following limits apply to the SDK in mini program plug-ins:

1. Automatic PVs are not supported.

2. Automatic tracking such as automatic click and exposure are not supported.

3. Visual tracking points are not supported.

4. Because the SDK cannot count the page address in the plug-in, the page reporting event in the plug-in must specify page_name in the event attribute, otherwise the statistical correlation calculation cannot be done.

4 Meaning of mini program scenarios

Quick Tracking collects the official scene values of each platform. The following links show the mapping documentation:

Baidu scenario value: https://smartprogram.baidu.com/docs/data/scene/

WeChat scenario value: https://developers.weixin.qq.com/minigame/dev/reference/scene-list.html

Byte Scene Value: https://microapp.bytedance.com/docs/zh-CN/mini-game/develop/framework/scene-value/

Alipay scenario value: https://opendocs.alipay.com/mini/framework/scene

QQ scene value: https://q.qq.com/wiki/develop/game/frame/scene/

5 Mini Program Sharing Recurring Definition

In the background of QuickTracking, the recurring metrics are defined based on the scenario values. The following table describes the parameters.

  1. WeChat: "small program message card in single chat session", "small program message card in group chat session", "App sharing message card", "small program message card with shareTicket", "chat record, open small program", "# topic page open small program", "open single page mode in circle of friends"

  2. Alipay: "Small program message card (share) in a single person chat session"

  3. Bytes: "WeChat Dialogue", "WeChat Friends Circle", "QQ Dialogue", "Qzone", "DingTalk", "System Sharing", "Copy Link", "Password Sharing", "Shared Micro Headlines"

  4. Baidu: "Share", "Share the original intermediate page", "Share the web-based intermediate page ", " Baidu Friends Chat Page Recurring Portal"

6 1.X Upgrade 2.X Operation Document

Replace SDK

2. The download address of version X SDK can be obtained by contacting your corresponding interface person.

After opening the address, click the blank space, right-click, save the SDK to the local, and drag the new SDK file into the project.

SDK introduction:

The receipt domain name field is changed from aplus-rhost-v to trackDomain'.

const aplus=require ('./utils/aplus_mini')(aplusConfig); Replace with:

// After the initQTSDK function is executed, the SDK is mounted under the context of the mini program, such as WeChat wx, byte tt, and Alipay my.
// The aplus and aplus_queue environment variables
import { initQTSDK } from './utils/qt_mini.umd.js';
initQTSDK(aplusConfig);

SDK 2.x provides two API calling methods:

  • Call the API directly by using the aplus environment variable

  • Send API commands to the aplus_queue of the SDK

Note: Choose one of the two methods and can be mixed.

1. Call an API operation by using the aplus environment variable

The code for direct API calls is more concise in the following format:

const { aplus } =Mini Program Platform Environment Variables // Such as WeChat wx, Alipay my, Byte tt, Baidu Swan, etc.
aplus.${APIName}($arguments) // The arguments are the input parameters 

of the specified API.

The APIName includes:

  1. setMetaInfo: overwrites the existing default settings of the SDK

  2. appendMetaInfo: the default configuration of the append SDK

  3. getMetaInfo: obtains the current configuration of the SDK.

  4. record: used to send event logs

  5. sendPV: used to send page logs

arguments are the input parameters for each API call

2. Send API commands to the aplus_queue queue

To send an API command to the SDK, you can send a command to the command queue aplus_queue of the SDK. The SDK executes the command. The command format is as follows:

const { aplus_queue } =Mini program platform environment variables; // such as WeChat wx, Alipay my, byte tt, and Baidu Swan.
aplus_queue.push({
  action: "$APIName",
  arguments: [$arguments], // The arguments are the input parameters of the specified API.
});
  • The action parameter represents the name of the API that sends the instruction. Its input parameter is a string and the value is an enumerated value. Available enumerated values are as follows

    • aplus.setMetaInfo: Overwrites the existing default settings of the SDK

    • aplus.appendMetaInfo: the default configuration of the append SDK

    • aplus.getMetaInfo: obtains the current configuration of the SDK.

    • aplus.record: used to send event logs

    • aplus.sendPV: used to send page logs

  • The arguments parameter is the input parameter of the API specified in the action. The format is an array. The order of the elements in the array is the same as the order of the input parameter defined by the API.

7. Other framework support capabilities

The WeChat mini program framework does not perform consistently on different platforms. In some PC environments, the lost pre-made page exit and application exit events are used.

8. About hooks

The SDK itself hooks the system onAppHide event. To ensure that the pre-built events page exit, page usage duration, application exit, and application usage duration are correctly collected, make sure that you do not perform time-consuming operations in the wx.onAppHide event.