All Products
Search
Document Center

Quick Tracking:uniapp SDK

Last Updated:May 16, 2025

In the uni-app framework, call the APIs of the Quick Tracking Statistics SDK to track statistics and report data.

1. Download the plug-in

Download URL of the QuickTracking uniapp Plug-in

Platform Compatibility

Android

iOS

Applicable version range: 4.4 - 13.0

Applicable version range: 9 - 15

Procedures:

1.1 Click Buy for Cloud Packaging

image

1.2 Select the project to integrate native plug-ins

image

1.3 Enter the package name of the application, and then confirm

image

Please note that the package name here must be the same as the package name filled in later when doing cloud packaging with HBuilder X tool.

2. Configure native plug-ins

2.1, open the HBuilder X tool, select the manifest.json file of the project that needs to integrate the plug-in, and follow the steps to check the App native plug-in configuration.

image

3. Tracking APIs

3.1 SDK initialization

App.vue

<script>
  // #ifdef APP-PLUS
  const QtAnalytics = uni.requireNativePlugin('qt-analytics-plugin');
  // #endif
  export default {
    onLaunch: function() {
      // #ifdef APP-PLUS
      QtAnalytics.setCustomDomain ('Set your domain name');
      if (uni.getSystemInfoSync().platform === 'ios') {
        /**
        * @description QtAnalytics.initWithAppkey(String appkey, String channel, int deviceType, String pushSecret)
        * @param {appkey} The unique identifier that is issued by the current application platform in the QT format.
        * @param {channel} The application market where the app is launched. 
        * @param {deviceType} device type, 1-mobile; 2-box (integer)
        * @param {pushSecret} is reserved but not used. Enter an empty string. (String type)  
        * */
        QtAnalytics.initWithAppkey ('Set iOS appKey', 'Set channel ', 1, '');
      } else {       
        /**
        * @description QtAnalytics.preInit(String appkey, String channel, int deviceType, String pushSecret)
        * @param {appkey} The unique identifier that is issued by the current application platform in the QT format.
        * @param {channel} The application market where the app is launched. 
        * @param {deviceType} device type, 1-mobile; 2-box (integer)
        * @param {pushSecret} is reserved but not used. Enter an empty string. (String type)  
        * */
        QtAnalytics.preInit ('Set Android appKey', 'Set channel ', 1, '');
        // Android needs to call QtAnalytics.init after the privacy authorization is approved. 
        QtAnalytics.init ('Set Android appKey', 'Set channel ', 1, '');
      }
      // #endif
    },
    onShow: function() {
      console.log('App Show')
    },
    onHide: function() {
      console.log('App Hide')
    }
  }
</script>

For H5 integration methods, please refer to the document: Web SDK

For more information about how to integrate mini programs, see Mini Program SDK.

3.2 Set Global Properties

1. Register global Properties API

/**
 * @description QtAnalytics.registerGlobalProperties(String params)
 * @params is a level -1 tile global parameter Property key-value pair. Nesting is not supported. Keys of the null and "" type are not supported on iOS.
 * @return void
 */
registerGlobalProperties(string params)

Examples:

QtAnalytics.registerGlobalProperties(JSON.stringify({
  "param_1":"value_1",
  "param_2":"value_2",
  "param_3":"value_3",
  "param_4":"undefined"
}));

2. Delete a global Property API

/**
 * @@description Deletes a global Property.
 * @param {key} Global Property name String type
 * @return void
 */
unregisterGlobalProperty(String key)

Examples:

 QtAnalytics.unregisterGlobalProperty('a');

3. Obtain all global Properties API

/**
 * @description Obtains all global Properties.
 * @return All global Property values are registered.
 */
getGlobalProperties

Examples:

const gp = QtAnalytics.getGlobalProperties();

4. Delete all global Properties API

/**
 * @description Deletes all global Properties.
 * @return void
 */ 
clearGlobalProperties

Examples:

QtAnalytics.clearGlobalProperties();

3.3 Page Browsing Events

/**Automatic page duration statistics to record the display duration of a page.
 Use the onPageStart and onPageEnd functions to complete automatic statistics. If only one function is called, no valid data is generated. 
 Call onPageStart when the page is displayed, and call onPageEnd when the page is exited.
 @ param viewName The name of the page on which statistics are collected.
 */
onPageStart(String viewName) // Start the page.
onPageEnd(String viewName) // The end of the page. 

Note: You must call the onPageStart() and onPageEnd() functions in pairs to complete automatic statistics. If only one function is called, valid data is not generated.

Examples:

//page.vue
const QtAnalytics = uni.requireNativePlugin('qt-analytics-plugin')

export default {
   onShow() {
     ...
     QtAnalytics.onPageStart ('Page code of the current page');
     ...
   }, 
   onHide() {
     ...
     QtAnalytics.onPageEnd ('Page code of the current page');
     ...
   },
}

Update page Properties

The page Property setting interface setPageProperty(), which supports attaching custom Properties to the current page.

/**
 * @pageName The name of the target page, which must be the same as the name of the current page. If not, the function execution is invalid
 * @pageProperty The k-v key-value pair parameter that is associated with the page. The value only supports strings and numbers, and does not support multi-layer nested objects.
 *
 * @warning Call description: You must call this operation before onHide.
 */
setPageProperty(String pageName, Object pageProperty)

Note: Set page Properties after you call the onPageStart operation.

Examples:

//page.vue
const QtAnalytics = uni.requireNativePlugin('qt-analytics-plugin')

export default {
   onShow() {
     ...
     QtAnalytics.onPageStart ('Page code of the current page');
     QtAnalytics.setPageProperty ('Page code of current page', {
      "pageparam_1":"value_1",
      "pageparam_2":"value_2",
      "pageparam_3":"value_3"
     })
     ...
   }, 
   onHide() {
     ...
     QtAnalytics.onPageEnd ('Page code of the current page');
     ...
   },
}

3.4 Custom events

/**
 * @description QtAnalytics.onEventObject(String eventId, String params)
 * @eventId Custom event name (string type)
 * @params Tiles custom parameter Property key-value pairs at one level. Nesting is not supported.
 */
onEventObject(String eventId, String params)

Examples:

QtAnalytics.onEventObject(
  'test_clk', 
  JSON.stringify({
      "product":"Water cup",
      "productColor":"Yellow",
      "productId":"003"
  })
);

3.5 User Login

onProfileSignIn(String puid, String provider = "'') The second parameter defaults to an empty string

QtAnalytics.onProfileSignIn('testUserId', 'testOrganization')

User Logout

QtAnalytics.onProfileSignOff()

Configure user Properties

You must first call the user login function to set the user ID, and then call the Set User Properties API. A type of custom event. The event code must be set to $$_ user_profile.

Examples:

/**
 * @description QtAnalytics.onEventObject(String eventId, String params)
 * @eventId must be written as $$_ user_profile
 * @params Tiles custom parameter Property key-value pairs at one level. Nesting is not supported. 
 */

QtAnalytics.onEventObject(
  '$$_user_profile', 
  JSON.stringify({
    "gender":"male",
    "_user_nick":"a_nick",
    "province":"Beijing"
  })
);

4. Run

  1. Package the custom base, select the plug-in, get the custom base, and then run time select the custom base, log output test.

  2. Formal cloud packaging after development

Paid native plug-ins currently do not support offline packaging.

Android Offline Packaging Native Plug-in Documentation

iOS Offline Packaging Native Plug-in Documentation

Note: If multiple package names are purchased and bound under the same plug-in and the same appid when using HBuilder X2.7.14 or later, and the cloud packaging interface prompts that the package name bindings are inconsistent, you need to delete the plug-in from the manifest.json-> App native plug-in configuration-> cloud plug-in list in the HBuilder X project and select it again.

5. Privacy and permission statements

1. The list of system permissions that the plug-in needs to apply for.

Android

  • android.permission.ACCESS_NETWORK_STATE

  • android.permission.ACCESS_WIFI_STATE

  • android.permission.INTERNETimageimage.png

iOS

  1. [Quick Tracking] By default, the SDK collects IDFAs to analyze and verify data more accurately. For the case that the application itself does not obtain idfa, it is recommended to configure the application as follows when submitting it to the AppStore: (in order to avoid being rejected by Apple for "the application does not contain advertising functions, but obtains the advertising identifier IDFA".) 1612266822165-29c8614c-00ce-4dd0-958e-76f02754d244.png

  2. The Quick Tracking SDK does not actively apply for the IDFA permission. If your app does not apply for the IDFA permission, Quick Tracking does not trigger a pop-up window to apply for the client permission.

2. The data collected by the plug-in, the server address to which the plug-in is sent, and the data usage description:

Android

QuickTracking Android SDK uniquely identify users by collecting unique device identification codes (such as Android ID, Serial (Android mobile phone device serial number), IMEI, IMSI, OAID, GAID, Mac, MCC (mobile country code), MNC (mobile network number)), so as to make data statistics such as user addition. Under special circumstances (such as when a user uses a tablet device or a TV box), the device cannot be identified by a unique device identification code. We will use the Mac address of the device as the unique identification of the user to provide normal statistical analysis services.

iOS

The QuickTracking iOS SDK uniquely identifies the user by collecting unique device identification codes (such as IDFA, IDFV, MCC (Mobile Country Code), MNC (Mobile Network Number), IP, UTDID) for data statistics such as user addition.

The server address of this product must be specified by the developer (privatized deployment). The parameter is obtained as follows:

appkey: obtained from the application list

Collection domain name: obtained in the "Management Console-Collect Information" module

SDK link: obtained in the "Management Console-Collect Information" module.

Privacy Protocol Address

6. Verify the tracking configuration

Android

In the manifest.json file, open "App Common Other Settings", find "Android Settings", and add "atm" to "UrlSchemes": The appKey of your Android application "to enable the application to be evoked by the specified connection scheme. image

iOS

In the manifest.json file, open "App Common Other Settings", find "iOS Settings", and add "atm" to "UrlSchemes": The appKey of your iOS application "to enable the application to be evoked by the specified connection scheme. image

For more information about how to verify the tracking points of mini programs and web applications, see Tracking Verification.

7. Auto-tracking function

Supported terminal

Features

Android

  • Application startup ($$_app_start)

  • Application exit ($$_app_end)

  • Application activation ($$_app_install)

iOS

  • Application startup ($$_app_start)

  • Application exit ($$_app_end)

  • Application activation ($$_app_install)

Web/H5

  • Page browsing ($$_page_start )

  • Page leave ($$_page_leave)

  • heatmap click ($$_hotpoint)

  • Auto Tap Auto Exposure

  • Automatic capture of arbitrary control clicks

WeChat mini program

  • Application startup ($$_app_start)

  • Application exit ($$_app_end)

  • Page browsing ($$_page_end )

  • Page bottoming ($$_reach_bottom)

  • Drop-down Refresh ($$_pull_down_refresh)

  • Share ($$_share)

  • Auto-click

  • Automatic Exposure

Alipay mini program

  • Application startup ($$_app_start)

  • Application exit ($$_app_end)

  • Page browsing ($$_page_end )

  • Page bottoming ($$_reach_bottom)

  • Drop-down Refresh ($$_pull_down_refresh)

  • Share ($$_share)

  • Auto-click

  • Automatic Exposure

Byte mini program

  • Application startup ($$_app_start)

  • Application exit ($$_app_end)

  • Page browsing ($$_page_end )

  • Page bottoming ($$_reach_bottom)

  • Drop-down Refresh ($$_pull_down_refresh)

  • Share ($$_share)

  • Auto-click

  • Automatic Exposure

Baidu mini program

  • Application startup ($$_app_start)

  • Application exit ($$_app_end)

  • Page browsing ($$_page_end )

  • Page bottoming ($$_reach_bottom)

  • Drop-down Refresh ($$_pull_down_refresh)

  • Share ($$_share)

  • Auto-click

  • Automatic Exposure