All Products
Search
Document Center

Quick Tracking:Common scenarios and tracking point suggestions

Last Updated:Jun 18, 2026

Covers common WebSDK scenarios such as event sending before page redirection, H5 tracking in apps and mini programs, automatic tracking, and custom cookie expiration.

1. Event sending before page redirection

Scenario Description

When a user clicks an anchor tag with an href attribute (for example, www.xxxx.com) on a web page, the click event may not be sent because the page redirects immediately. To ensure the data is sent, report the click event before the page redirects.

Example:

// Click the link.
function targetLinkCLK(url) {
  aplus_queue.push({
    action: 'aplus.record',
    arguments:['track_alink_clk', 'CLK', {
      param1: "xxxx",
      param2: "xxxx",
    }],
  });
  window.location.href = url;
};

In extreme cases where the event still cannot be sent, you can delay the page redirection. The sample code is as follows:

// Click the link.
function targetLinkCLK(url) {
  // Delay page redirection and reserve the amount of time for the SDK to send the page.
  setTimeout(function(){
    window.location.href = url;
   }, 500);
  aplus_queue.push({
    action: 'aplus.record',
    arguments:[ 'track_alink_clk', 'CLK', {
      param1: "xxxx",
      param2: "xxxx",
    }],
  });
}

2 How to track H5 pages in an app

For H5 tracking in Android, see:

Android App H5 Bridge Operations Documentation

For H5 tracking in iOS, see:

H5 Bridge in iOS App

3 How to track H5 pages in mini programs

For H5 tracking in mini programs, see:

H5 embedded tracking operation document in mini programs

4 H5 automatic tracking

Auto-tracking feature

Description

Documentation

Page Events

When a page is loaded and the onload lifecycle function is triggered, a page view event is automatically reported. The default event parameters are:

url: page URL with parameters

ref_url: document.referrer

page_name: page URL without parameters

page_title: document.title

Enable /disable /configure page tracking

Click event

Tracks clicks on elements of a specified tag type. When an element of this type is clicked, a click event is automatically reported. The default event parameters are:

url: page URL with parameters

ref_url: document.referrer

page_name: page URL without parameters

page_title: document.title

Additional parameters: control ID, control type, control filter, control location, control content, control name, and control style name.

Automatic capture of any control click

Tracks clicks on elements of a specified CSS class. When an element of this class is clicked, a click event is automatically reported. The default event parameters are:

url: page URL with parameters

ref_url: document.referrer

page_name: page URL without parameters

page_title: document.title

Auto-click of a specified element

Tracks exposure of elements of a specified tag type. When an element of this type becomes visible in the viewport, an exposure event is automatically reported. The default event parameters are:

url: page URL with parameters

ref_url: document.referrer

page_name: page URL without parameters

page_title: document.title

Specify the automatic exposure of an element

5. Customize the expiration time of the cookie written by the SDK

As privacy compliance policies become stricter, some regions require cookie expiration times to not exceed one year. The SDK allows you to set a custom expiration time (in days) for the cookies it writes.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="qt-cookie-expires" content="180">
    ....js
</head>
<body></body>
</html>

To customize the cookie expiration time, add a meta tag named qt-cookie-expires as shown in the preceding code.

Detailed Description:

Parameter

Meaning

Documentation

qt-cookie-expires

Custom cookie expiration time for the SDK

The number of days from the current access time until the cookie expires.

Minimum value: 1

Maximum value: 20*365

The default expiration time is 365 days.