Skip to main content

JS

Last updated 10/07/2026

Latest version: v1.0.0

Update time: 2026-07-24

Downloads: Download

1. Overview​

Starting from version 6.1, AE adds the experiment suite feature. You can create experiments in the AE backend, set the variable values for the control group and experiment groups, and pull them to your app through the client SDK to show different content to users in different groups.

This article describes how to integrate the client SDK. On the app side, you only need to handle interactions with the ThinkingData SDK and don't need to care about task details in the AE backend.

Note that the experiment SDK must be used together with the Config Center SDK.

2. Integration​

2.1 Integrate the SDK manually​

Config Center depends on the following ThinkingData SDKs:

SDK nameDescriptionVersion requirement
TDAnalyticsCollects and processes data>= 2.6.0
TDRemoteconfigFetches configuration from the AE backend>= 1.3.0
  1. Click the download link at the top of this page to download the SDK, and then unzip it
  2. Drag thinkingdata.umd.min.js, tdremoteconfig.umd.min.js, and tdexperiment.umd.min.js into the same directory of your project

3. Initialization​

After you switch to this integration method, use the TDApp instance to initialize the SDK, and use the window.thinkingdata instance for other data collection and reporting.

<script src="./thinkingdata.umd.min.js"></script>
<script src="./tdremoteconfig.umd.min.js"></script>
<script src="./tdexperiment.umd.min.js"></script>
//Initialize the data collection SDK
window.ta = thinkingdata;
ta.init({
appId: 'APP_ID',
serverUrl: 'https://YOUR_SERVER_URL',
});
//Initialize the experiment SDK
TDExperiment.init({
appId: 'APP_ID',
serverUrl: 'https://YOUR_SERVER_URL',
automaticExposureTracking: true,
customBucketId:{},
customFetchParams: {},
enableLog: true,
onFetchSuccess: function () {
},
onFetchFailure: function (code, msg) {

}
});

Initialization parameters:

  • appId:APP ID
  • serverUrl: the data receiving URL
  • automaticExposureTracking: defaults to true. Exposure events are uploaded automatically when you call get to retrieve experiment parameters
  • customBucketId: the custom bucket key
  • customFetchParams: custom parameters on the client config channel
  • enableLog: whether to enable debug logs
  • onFetchSuccess: the experiment configuration is fetched successfully
  • onFetchFailure: the experiment configuration fails to be fetched

4. Usage​

4.1 Get experiment information​

TDExperiment.getValueAsString(key)

TDExperiment.getValueAsNumber(key)

TDExperiment.getValueAsBoolean(key)

TDExperiment.getValueAsJson(key)

If automaticExposureTracking is true, exposure events are uploaded automatically when you call get

4.2 Upload exposure events​

You can call the exposure method to upload exposure events manually

TDExperiment.exposure(key);

4.3 Proactively fetch all experiment information​

TDExperiment.fetch();

TDExperiment.fetch().addOnSuccessListener(function () {
//Success
}).addOnFailureListener(function (code, msg) {
//Failure
});

4.4 Custom bucket key​

TDExperiment.setCustomBucketId({
'bucket_id':'account_id'
});

4.5 Custom request parameters​

TDExperiment.setCustomFetchParams({
'key':'value'
});
Was this page helpful?