Use the QuickTracking Web SDK to send event and page view logs through an instruction-based API.
1. SDK overview
1.1. How it works
The SDK uses an instruction-based API. Push instructions to the `aplus_queue` queue of the `aplus` environment variable:
aplus_queue.push({
'action': "$APIName",
'arguments': [$arguments] // arguments are the input parameters for the specified API.
})
-
The `action` parameter specifies the API name. Accepted values:
-
`setMetaInfo`: Overwrites SDK default configurations.
-
`appendMetaInfo`: Appends to SDK default configurations.
-
`getMetaInfo`: Retrieves the current SDK configuration.
-
`record`: Sends event logs.
-
`sendPV`: Sends page view (PV) logs.
-
`recordAppLink`: Sends application launch events.
-
-
The `arguments` parameter is an array of input parameters for the specified API, in the same order as the API definition.
1.2. Example
// Change the default settings of the SDK.
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: [metaName, metaValue]
});
// Get the current configuration of the SDK.
aplus.getMetaInfo(metaName);
// Send an event log.
aplus_queue.push({
action: 'aplus.record',
arguments: [trackerEventCode, eventType, eventParams]
});
// Send a page log.
aplus_queue.push({
action: 'aplus.sendPV',
arguments: [pageEventConfig, userData]
});
2. Log printing
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['DEBUG', true]
});
3. Log sending policy
Logs are sent in near real-time when events are triggered.
4. Application configuration
Modify or append default configurations when importing the SDK.
// The appKey of the integrated application.
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['appKey', 'Your_AppKey']
})
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['trackDomain', 'Your_Data_Collection_Service_Endpoint']
});
// Enable debug mode.
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['DEBUG', true]
});
|
MetaName |
Description |
metaValue description |
Supported versions |
|
DEBUG |
Outputs SDK instrumentation logs to the console. |
`true` enables logs. `false` disables logs. |
all |
|
appVersion |
Current version of the web application. |
Your web application version string. |
all |
|
appKey |
The `appKey` assigned when you created the application. |
Get the `appKey` from the platform. |
all |
|
aplus-rhost-v |
Data collection domain name (Deprecated). |
Get from the platform. |
all |
|
trackDomain |
Data collection domain name. |
Get from the platform. |
v2.0.0 and later |
|
_dev_id |
Custom device ID. |
Overwrites the auto-generated QuickTracking device ID. |
all |
|
_user_id |
Sets the user ID. |
A custom login account ID for your business. |
all |
|
_hold |
Sends a hold signal. Set `_hold` multiple times during the SDK lifecycle, but `BLOCK` and `START` must be used in pairs. Otherwise, log sending is affected. |
Enumeration values:
|
all Note: This applies only to API calls made using `aplus_queue.push`. |
|
aplus-jsbridge-only |
H5 log reporting switch. |
|
all |
|
aplus-utm-expire-days |
Sets the expiration time for UTM parameters. |
UTM parameters are valid for the current session by default. Set a custom expiration in days. The value is stored in a cookie, subject to the browser's cookie expiration limit. |
v2.0.7 and later |
|
aplus-preset-events-disabled |
Disables default prebuilt events collected by the SDK. |
Default: `undefined`. Assign an array to disable specific events. Example:
|
v2.0.9 and later |
5. Data collection switch
Data collection is enabled by default. Use the enable and disable APIs to control it. Available in v2.2.2 and later.
Data collection is enabled by default. Unless a developer sets or deletes the `aplus-sdk-disable` field in local storage, data collection remains active.
5.1. Enable data collection
enableSDK
Example:
5.1.1. Synchronous integration
<script src='SDK_URL' charset="UTF-8"></script>
<script>
aplus.initParams({
appKey: "Your_AppKey",
trackDomain: 'Your_Data_Collection_Domain',
...
'disableSDK': false // Enable data collection (enabled by default).
});
</script>
5.1.2. Asynchronous integration (instruction queue)
// Enable data collection.
window.aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['aplus-sdk-disable', false]
})
5.1.3. Asynchronous integration (API)
// Enable data collection.
window.aplus.enableSDK();
5.2. Disable data collection
disableSDK
Example:
5.2.1. Synchronous integration
<script src='SDK_URL' charset="UTF-8"></script>
<script>
aplus.initParams({
appKey: "Your_AppKey",
trackDomain: 'Your_Data_Collection_Domain',
...
'disableSDK': true // Disable data collection.
});
</script>
5.2.2. Asynchronous integration (instruction queue)
// Disable data collection.
window.aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['aplus-sdk-disable', true]
})
5.2.3. Asynchronous integration (API)
// Disable data collection.
window.aplus.disableSDK();