Menu

WeChat Mini Game SDK

1. SDK Basic Information

SolarEngine (SE) is an all-in-one mobile app growth analytics and data intelligence platform, designed to assist developers to monitor every stage of business development. We provide both fixed analysis reports and highly customizable data analytics services, allowing developers to personalize configurations across multiple aspects, including data tracking, property settings, report creation, and dashboard configuration.

Privacy Policy:  https://www.solar-engine.com/privacyPolicyEN.html


2. Before you start

2.1. Get User Code

Access Path: Account Management - Account Profile - Secret - User Code

2.2. Get AppKey

      Access Path: Asset Management - App Management - AppKey

2.3. Obtain SDK

Download SDK (UMD and ES packages provided) :

     https://sdk.solar-engine.com/MiniWx/SolarEngine-MiniWx-CN-SDK-1.3.5.zip  

2.4. Configure Weixin Official Accounts Platform

  • Get AppID and AppSecret

     Log in to「Weixin Official Accounts Platform」and go to the homepage > 开发管理 > 开发设置 > 开发者ID. Then copy the AppID (Mini Program ID) and AppSecret (Mini Program Secret), and paste them into SE dashboard.

  • Server Domain Configuration

     Log in to「Weixin Official Accounts Platform」, go to the homepage > 开发管理 > 开发设置 > 服务器域名 > request 合法域名, and enter the following domains to complete the configuration (see example screenshot):

  • https://api-receiver.detailroi.com
  • https://rule.detailroi.com

  • IP Whitelist Configuration

     Log in to「Weixin Official Accounts Platform」, go to the homepage > 开发管理 > 开发设置 > 开发者ID > IP白名单

  • If the IP whitelist protection is not enabled, there is no need to configure the SE fixed IPs.
  • If the IP whitelist protection is already enabled, you need to add the following SE fixed IPs:
    • 71.132.0.102
    • 52.81.1.45
    • 52.54.188.146
    • 34.196.30.48

  • If you need to integrate Tencent Mini Game Ads SDK, please refer to the configuration of 3.1. in documentation.

3. Initialize the SDK

3.1. SDK initialization

     It is recommended to import and initialize SDK in the entry JS file of your Mini Game project to ensure data accuracy. Before initializing the SDK, you need to perform pre-initialization by calling the prevInit method and passing in the appKey.

     Note: The SDK should only be imported once in one Mini Game. After importing the SDK in app.js, it is recommended to mount it to the global scope (e.g. globalThis) for use elsewhere.

Import the ES format file for ES Modules environments; otherwise, use the UMD format.
// game.js
import SESDK from './miniwx-cn-sesdk-umd.js';

// Some platforms only support CommonJS imports, in which case please use require. 
//  const SESDK = require('./miniwx-cn-sesdk-umd.js')

// Pre-initialization
SESDK.prevInit('appKey'); 
// Initialization
SESDK.init(initParams);
// Mount to global (e.g. globalThis) for use elsewhere
globalThis.SESDK = SESDK;

initParams parameter description:

ParameterTypeRequiredDescription
userIdstringYESUserCode obtained above
appKeystringYESAppKey obtained above
unionidstringNoMini Game Union ID
openidstringNoMini Game Open ID (If not provided, SDK will obtain automatically, but you must fill in the AppID and AppSecret on SE dashboard following 2.4.)
configConfigNoInitialization related config

Config parameter description:

ParameterTypeRequiredDescription
debugModelbooleanNoWhether to enable the debugging mode (Default false)
logEnabledbooleanNoWhether the console prints SDK logs (Default false)
isInitTencentAdvertisingGameSDKbooleanNoWhether to initialize Tencent Mini Game Ads SDK (Default false)
tencentAdvertisingGameSDKfunctionNoReference to the Tencent Mini Game Ads SDK class. Download it according to the Tencent Mini Game Ads SDK integration guide. If you are developing a Mini Game on the Cocos Creator platform, manually download and import the UMD build (Download Link).
reportingToTencentSdknumberNoWhether to report the launch event to Tencent. Default 3.
1: Report all data to Tencent
2: Report partial data to Tencent
3: Do not report to Tencent
tencentAdvertisingGameSDKInitParamstencentSDKInitParamsNoRequired parameters for initializing the Tencent Mini Game Ads SDK.
tencentSdkIsAutoTrackbooleanNoWhether the Tencent SDK automatically collects data. Default true.

tencentSDKInitParams parameter description:

ParameterTypeRequiredDescription
user_action_set_idnumberYESData source ID
secret_keystringYESEncryped key
appidstringYESWeChat Mini Game AppID; start with "wx"

Sample Code

// Load Tencent Mini Game Ads SDK
import { SDK } from './dn-sdk-minigame/index.js';

SESDK.prevInit('666666');
SESDK.init({
  appKey: '666666',
  userId: '888888',
  openid: 'xxxxxxxxxxx',
  config: {
    logEnabled: true,
    isInitTencentAdvertisingGameSDK: true,
    tencentAdvertisingGameSDK: SDK,
    tencentAdvertisingGameSDKInitParams: {
       user_action_set_id: 'xxx',
       secret_key: 'xxx',
       appid: 'xxx'
    }
  },
});

// Import with CocosCreator platform
import TencentSDK from './dn-sdk-minigame/index.umd.js';
SESDK.prevInit('666666');
SESDK.init({
  appKey: '666666',
  userId: '888888',
  openid: 'xxxxxxxxxxx',
  config: {
     logEnabled: true,
     isInitTencentAdvertisingGameSDK: true,
     tencentAdvertisingGameSDK: TencentSDK.SDK,
     tencentAdvertisingGameSDKInitParams: { 
        user_action_set_id: 'xxx', 
        secret_key: 'xxx', 
        appid: 'xxx'
     } 
  },
});

   Since the SDK initialization logic runs asynchronously, if your business logic needs to be executed after SDK initialization is complete, you may call the ready method.

SESDK.ready(callback);

   During SDK initialization, if you need to load SDK plugins, you may call the use method.

SESDK.use(sdkPlugin);

3.2. Visitor ID

      Visitor ID refers to the user's unique identifier (_visitor_id) after install and before login.

      We provide an interface for developers to customize the visitor ID. If you have your own visitor management system and need to replace SolarEngine's visitor ID, you must set it before SDK initialization.

      Only the last visitor ID passed in will be used for data reporting. Multiple calls should be avoided to prevent abnormal situations where multiple visitor IDs are reported consecutively.

Set visitor ID

       Call setVisitorID to set the visitor ID:

SESDK.setVisitorId('vid8709901241')

Note:

  • This call only passes the visitor ID to SDK and does not report user setting events.
  • The length of the visitor ID set by the developer cannot exceed 128 characters, otherwise the setting will fail.
  • Once set by the developer, it will be stored in local storage.

Obtain visitor ID

   Call getVisitorId to get the current visitor ID:

SESDK.getVisitorId()


3.3. Account ID

       Account ID refers to the unique identifier for users who finished login within the app. Prior to login, the visitor ID will be used as the user identifier.

      Once the account ID is set, it will be retained permanently until the logout method is called to clear the account ID. The logout method should only be called when users actually log out, but no need to be called when the app is closed or running in the background.

      Only the last passed account ID will be used for data reporting. Multiple calls should be avoided to prevent abnormal situations where multiple abnormal account IDs are reported consecutively.

Set Account ID

      Call login to set the user's account ID:

SESDK.login('aid25491084');

Note:

  • This call only passes the account ID to SDK and does not report user login events.
  • The account ID set by the developer cannot exceed 128 characters, otherwise the setting will fail.
  • Once set by the developer, it will be stored in local storage.

Obtain account ID

       Call getAccountId to get the user's account ID:

SESDK.getAccountId();

Clear account ID

       Call logout to clear the account ID:

SESDK.logout();

Note:

       This call only notifies the SDK to clear the account ID and will not report the user logout event.


3.4. Public event properties

      Public event properties are included in every event, such as the user's source channel and the advertising ID associated with conversions.

      You can call setSuperProperties function to set public event properties. We recommend you setting the public event properties before sending any events.

      The format of public event properties are the same as custom properties --> 4.4 Custom Properties

SESDK.setSuperProperties({
   key: value
});

       If you need to delete a public event property, you can call unsetSuperProperty to clear one of them.

SESDK.unsetSuperProperty(key);

       If you want to clear all public event properties, you can call clearSuperProperties .

SESDK.clearSuperProperties();

Note:

  1. If you call setSuperProperties to upload public event properties that have been set previously, the new values will overwrite the existing ones.
  2. If a property key in a normal event is the same as a public event property key, the normal event property will override the public event property.
  3. Once set by the developer, these properties will be stored in local storage.

3.5. Preset event properties

   The SolarEngine SDK supports developers to set custom properties for the two preset events: install, and app open.

SESDK.setPresetEvent(eventType, properties);
ParameterDescriptionParameter TypeRequired
eventTypee.g.
_mpInstall
_mpStart
_mpEnd
all (all preset events)
stringYES
propertiesCustom propertiesobjectNO

Note:

  • Preset event properties should be set before SDK initialization. In this way, the properties will apply to all subsequent preset events reported by the SDK. If set later, the preset events generated before setting will not include these custom properties.
  • Custom preset event properties are not cached. Only the last setting will take effect if multiple settings are made for the same preset event.
  • If the enumeration for eventType is set to all, it will overwrite the custom properties set in webInstall and webStart enumerations. If set multiple times, only the last setting takes effect.
  • Custom properties set for preset events can be cleared by calling the corresponding enumeration, as shown below:

SESDK.setPresetEvent('webInstall', null)  This method can be used to clear webInstall custom properties, while webStart custom properties can be cleared by changing to the corresponding enumeration value.

  • Additionally, SolarEngine SDK supports globally clearing custom properties for all preset events, as shown below:

SESDK.setPresetEvent('all', null)  This method clears the custom properties for all preset events, including those set via the webInstall and webStart enumerations.

Code Example:

SESDK.setPresetEvent('webInstall', {
  k1: 'v1',
  k2: 'v2'
});


3.6. Set other properties

3.6.1. Set channel name

       Call setChannel method to set the channel name "_channel".

SESDK.setChannel('channel');      

3.6.2. Set referrer page title

       Call setReferrerTitle method to set the referrer page title information "_referrer_title".

SESDK.setReferrerTitle('title');      

3.6.2. Set current page title

       Call setXcxPageTitle method to set the current page title information "_page_title".

SESDK.setXcxPageTitle('title');      

3.7. Get distinct_id & distinct_id_type

       Call getDistinct method to retrieve distinct_id and distinct_id_type. This method returns a Promise object.

SESDK.getDistinct().then(data => {
   // data.result.distinct_id
   // data.result.distinct_id_type
})
distinct_id_typeDescription
1101openid
1103uuid
Note:openid > uuid


3.8. Get Attribution Results

3.8.1. Set Attribution Callback Listener

       Developers can set a callback listener for attribution results. This method can only be called once and returns a Promise object.

SESDK.setOnAttributionListener().then(res => {
   // res.result
})

3.8.2. Actively Retrieve Attribution Results

       Developers can actively retrieve attribution results. This method can be called multiple times and returns a Promise object.

SESDK.getAttribution().then(res => { 
     // res.result
})

Attribution Results Example

Re-engagement attribution results will be displayed in "re_data".

{
            //New user attribution results
            "account_id": "",
            "ad_type": "",
            "adcreative_id": "",
            "adcreative_name": "",
            "adcreative_type": "",
            "adgroup_id": "",
            "adgroup_name": "",
            "adplan_id": "",
            "adplan_name": "",
            "attribution_time": "2023-08-31 11:16:35",
            "attribution_touch_type": "",
            "attribution_type": "",
            "callback_id": "",
            "channel_id": "-1",
            "channel_name": "organic",
            "click_id": "",
            "conversion_id": "",
            "custom_params_1": "",
            "custom_params_10": "",
            "custom_params_2": "",
            "custom_params_3": "",
            "custom_params_4": "",
            "custom_params_5": "",
            "custom_params_6": "",
            "custom_params_7": "",
            "custom_params_8": "",
            "custom_params_9": "",
            "impression_id": "",
            "install_time": "2023-08-31 11:16:32",
            "placement_id": "",
            "report_time": "2023-08-31 11:16:34",
            "request_id": "",
            "ry_touchpoint_ts": "",
            "site_id": "",
            "site_name": "",
            "turl_campaign_id": "",
            "turl_campaign_name": "",
            "turl_id": "",
            "re_data": {
                //Re-engagement attribution results
                "account_id": "",
                "ad_type": "",
                "adcreative_id": "",
                "adcreative_name": "",
                "adcreative_type": "",
                "adgroup_id": "",
                "adgroup_name": "",
                "adplan_id": "",
                "adplan_name": "",
                "attribution_time": "2023-08-31 11:16:35",
                "attribution_touch_type": "",
                "promotion_objectives": "",
                "callback_id": "",
                "channel_id": "-1",
                "channel_name": "organic",
                "click_id": "",
                "conversion_id": "",
                "custom_params_1": "",
                "custom_params_10": "",
                "custom_params_2": "",
                "custom_params_3": "",
                "custom_params_4": "",
                "custom_params_5": "",
                "custom_params_6": "",
                "custom_params_7": "",
                "custom_params_8": "",
                "custom_params_9": "",
                "impression_id": "",
                "install_time": "2023-08-31 11:16:32",
                "placement_id": "",
                "report_time": "2023-08-31 11:16:34",
                "request_id": "",
                "ry_touchpoint_ts": "",
                "site_id": "",
                "site_name": "",
                "turl_campaign_id": "",
                "turl_campaign_name": "",
                "turl_id": ""
            }
        }

attributionData parameter description:

ParameterExampleDescription
attribution_touch_typeclick, impressionAttribution touchpoint type
ry_touchpoint_tsAttribution display or click time (YYYY-MM-DD HH:MM:SS)Attribution touchpoint time
install_timeDevice activation time (YYYY-MM-DD HH:MM:SS)Activation time
attribution_time2022/5/11 15:00:03Attribution time
turl_campaign_id3e0a9bad8455d685eaaf91bad71bdeb2Tracking link ID
turl_campaign_nameMintegral_trackingTracking link name
turl_idUfeE7zaShort link ID
channel_id1234Channel ID
channel_namemintegralAttribution channel name
attribution_typeuaUA (indicates new user acquisition)
account_id,Channel promotion account ID
adgroup_id,Channel promotion ad group ID
adgroup_name,Channel promotion ad group name
adplan_id,Channel promotion plan ID
adplan_name,Channel promotion plan name
adcreative_id,Channel promotion creative ID
adcreative_name,Channel promotion creative name
adcreative_type,Channel promotion creative type
site_id,Sub-channel ID
site_name,Sub-channel name
ad_type,Channel promotion ad type
placement_id,Channel promotion ad placement ID
conversion_id,Ad placement ID
click_id,Channel promotion unique click ID
impression_id,Channel promotion unique impression ID
request_id,Ad request ID
callback_idEJiw267wvfQCGKf2g74ZIPD89-vIATAMOAFCIjIwMTkxM
TI3MTQxMTEzMDEwMDI2MDc3MjE1MTUwNTczNTBIAQ==,
Callback ID
custom_params_1Predefined tracking link parameter 1-10
custom_params_2Predefined tracking link parameter 1-10
custom_params_3Predefined tracking link parameter 1-10
custom_params_4Predefined tracking link parameter 1-10
custom_params_5Predefined tracking link parameter 1-10
custom_params_6Predefined tracking link parameter 1-10
custom_params_7Predefined tracking link parameter 1-10
custom_params_8Predefined tracking link parameter 1-10
custom_params_9Predefined tracking link parameter 1-10
custom_params_10Predefined tracking link parameter 1-10


4. Event Reporting

  After SDK is initialized, you can call the following methods to report other event data, which can be categorized into the following four types:

1. Preset Events: These events are triggered and reported automatically by the SDK according to preset rules. They have specific _event_name such as webInstall, webStart.

2. Predefined Events: These events have predefined definitions and event names in the system. They require developers to report data when those events are triggered, such as in-app ad impression, in-app purchase, etc.

3. Custom Events: These events can be custom defined by developers according to their own analytical needs.

4. Duration Events: These events track the duration of a specific event.

Note:

  The event name supports uppercase and lowercase English characters, numbers, and underscores. The length cannot exceed 40 characters.

4.1. Preset events

1) Install

       This event is automatically reported when users first open Mini Game. (If a user deletes the Mini Game and opens again, it will count as a new install.)

       The _event_name is _mpInstall.

2) Start

       This event is automatically reported every time the Mini Game is opened or brought to foreground from background.

       The _event_name is _mpStart.

3) End

       This event is automatically reported every time the Mini Game is brought to background from foreground.

       The _event_name is _mpEnd.

4.2. Predefined events

1) Ad Impression

       Automatically reported every time an ad gets displayed.

SESDK.trackAdImpression(data)

Parameter description:

Parameter NameParameter MeaningParameter TypeRequired
adNetworkPlatformMonetization platform (Value: platform name)
csj: 穿山甲 China Mainland version
pangle: 穿山甲 Non-China-Mainland version
tencent: 腾讯优量汇
baidu: 百度百青藤
kuaishou: 快手
oppo: OPPO
vivo:vivo
mi: 小米
huawei: 华为
applovin: AppLovin
sigmob: Sigmob
mintegral:Mintegral
oneway: OneWay
vungle: Vungle
facebook: Facebook
admob: AdMob
unity: UnityAds
is: IronSource
adtiming: AdTiming
klein: 游可赢
fyber: Fyber
chartboost: Chartboost
adcolony: Adcolony
Stringyes
adTypeAd types:
1:Rewarded Video
2:Splash
3:Interstitial
4:Fullscreen Video
5:Banner
6:Native
7:Native Video
8:Banner (MPU)
9:Instream Video
10:MREC
0:Other
Numberyes
adNetworkAppIDThe App ID on monetization platforms.Stringno
adIDThe Placement ID on monetization platforms.Stringyes
mediationPlatformMediation platforms commonly used:
max
ironsource
admob
hyperbid
topon
cas
Tradplus
Tobid

If your mediation platform is not on the list, you can name it yourself, only that the name cannot exceed 32 characters.
Send "custom" if no mediation platform is used.
Stringyes
ecpmAdvertising eCPM (revenue per thousand ad impressions, 0 or negative means no data transmitted)numberyes
currencyRevenue Currency Type (following ISO 4217)
e.g. CNY, USD
Stringyes
renderedWhether the ad is rendered successfully.
YES: success
NO: Failed.
If you do not need to pass in this indicator, please pass YES.
Booleanyes
customProperties/Objectno

Code Example:

SESDK.trackAdImpression({
  adNetworkPlatform: 'oppo',
  adType: 1,
  adNetworkAppID: '123',
  adId: '123',
  mediationPlatform: 'custom',
  ecpm: 13.140001,
  currency: 'USD',
  rendered: true,
  customProperties: {
    one: '1',
  }
})

2) Ad Click

   Automatically reported when ads are clicked.

SESDK.trackAdClick(data)

Parameter description:

Parameter NameParameter MeaningParameter TypeRequired
adNetworkPlatformMonetization platforms, for example (value: name),
csj:穿山甲国内版
pangle:穿山甲国际版
tencent:腾讯优量汇
baidu:百度百青藤
kuaishou:快手
oppo:OPPO
vivo:vivo
mi:小米
huawei:华为
applovin:Applovin
sigmob:Sigmob
mintegral:Mintegral
oneway:OneWay
vungle:Vungle
facebook:Facebook
admob:AdMob
unity:UnityAds
is:IronSource
adtiming:AdTiming
klein:游可赢
fyber:Fyber
chartboost:Chartboost
adcolony:Adcolony
Stringyes
adTypeAd types:
1:Rewarded Video
2:Splash
3:Interstitial
4:Fullscreen Video
5:Banner
6:Native
7:Native Video
8:Banner (MPU)
9:Instream Video
10:MREC
0:Other
Numberyes
adIDThe Placement ID on monetization platforms.Stringyes
mediationPlatformMediation platforms commonly used:
max
ironsource
admob
hyperbid
topon
cas
Tradplus
Tobid

If your mediation platform is not on the list, you can name it yourself, only that the name cannot exceed 32 characters.
Send "custom" if no mediation platform is used.
Stringyes
customProperties/Objectno

Code Example

SESDK.trackAdClick({
  adNetworkPlatform: 'oppo',
  adType: 1,
  adId: '123',
  mediationPlatform: 'custom',
  customProperties: {
    one: '1',
  }
})

3) In-app Purchase

    It shall be triggered as users make a purchase.

SESDK.trackIAP(data)

Parameter description:

Parameter NameParameter MeaningParameter TypeRequired
reportingToTencentSdkReport events to Tencent. Required if Tencent Ads SDK is initialized.
1: Full reporting
2: Partial reporting
3: No reporting
numberyes
orderId The order ID generated by the system for this purchaseStringno
payAmountThe amount paid for this purchase (Unit: yuan)Numberyes
currencyTypeThe currency type of payment (following ISO 4217)Stringyes
payTypePayment methods, such as alipay, weixin, applepay, paypal, etc.Stringno
productIDPurchased item IDStringno
productNamePurchased item nameStringno
productCountQuantity of items purchasedNumberno
payStatusPayment status
1: success
2: fail
Numberyes
failReasonReason for payment failureStringno
customProperties/Objectno

Note:

The failureReason parameter should only be passed in when payStatus is 2 (fail). For other statuses, simply pass "".

Code Example:

SESDK.trackIAP({
  orderId: '12345678',
  payAmount: 1234.5678,
  currencyType: 'USD',
  payType: 'alipay',
  productID: '12345678',
  productName: 'this is product name',
  productCount: 10,
  payStatus: 1,
  failReason: 'this is fail reason',
  customProperties: {
    one: '1',
  }
})

4) Self-Reported Attribution Results

     This feature allows developers to send attribution data from a third-party or self-attribution platform to SolarEngine. The reporting timing can be customized by developers. (Event Name: "_mpAttr")

SESDK.trackAppAttr(data)

Parameter description:

Parameter NameParameter MeaningParameter TypeRequired
adNetworkChannel ID (should match the channel ID in ROI analysis)Stringyes
subChannelSub-channels for advertisingStringno
adAccountIDAd account ID for advertisingStringno
adAccountNameAd account name for advertisingStringno
adCampaignIDAd campaign ID for advertisingStringno
adCampaignNameAd campaign name for advertisingStringno
adOfferIDAd offer ID for advertisingStringno
adOfferNameAd offer name for advertisingStringno
adCreativeIDAd creative ID for advertisingStringno
adCreativeNameAd creative name for advertisingStringno
attributionPlatformMonitoring PlatformStringyes
customProperties/Objectno

Sample code:

SESDK.trackAppAttr({
  adNetwork: '123456',
  subChannel: '123456',
  adAccountID: '123456',
  adAccountName: '123456',
  adCampaignID: '123456',
  adCampaignName: '123456',
  adOfferID: '123456',
  adOfferName: '123456',
  adCreativeID: '123456',
  adCreativeName: '123456',
  attributionPlatform: '123456',
  customProperties: {
  	one: '1',
  }
})

5) In-App Order

       It shall be triggered as users initiate an order.

SESDK.trackOrder(data)

Parameter description:

Parameter NameParameter MeaningParameter TypeRequired
orderIDOrder IDStringNo
payAmountThe payment amount of the order (Unit: yuan)NumberYes
currencyTypeThe currency type of the order (following ISO 4217)StringYes
payTypePayment methods, such as alipay, weixin, applepay, paypal, etc.StringNo
statusOrder StatusStringYes
customProperties/ObjectNo

Code Example:

SESDK.trackOrder({
  orderId: '12345678',
  payAmount: 1234.5678,
  currencyType: 'USD',
  payType: 'alipay',
  status: 'this is fail status',
  customProperties: {
    one: '1',
  }
})

6) Registration event

       It shall be triggered as users register.

SESDK.trackRegister(data)

Parameter description:

Parameter NameParameter MeaningParameter TypeRequired
reportingToTencentSdk Report events to Tencent. Required if Tencent Ads SDK is initialized.
1: Full reporting
2: Partial reporting
3: No reporting
numberYes
registerType Registration types such as "WeChat", "QQ" and other custom valuesStringYes
registerStatusRegistration status such as "success"StringNo
customProperties/ObjectNo

Code Example:

SESDK.trackRegister({
  regType: 'WeChat',
  registerStatus: 'success',
  customProperties: {
    one: '1',
  }
})

7) Login event

      It shall be triggered as users login.

SESDK.trackLogin(data)

Parameter description:

Parameter NameParameter MeaningData TypeRequired
loginTypeLogin type such as "WeChat", "QQ" and other custom valuesStringYes
loginStatusLogin status such as "success"StringNo
customProperties/ObjectNo

Code Example

SESDK.trackLogin({
  loginType: 'WeChat',
  loginStatus: 'success',
  customProperties: {
    one: '1',
  }
})

8) Reactivation event

       Triggered when a previously registered Mini Game user returns after becoming inactive. The recommended inactivity thresholds are 7, 14, or 30 days. However, any custom N (days) is supported. The corresponding _event_name is _mpReActive.

SESDK.trackReActive(data)

data: object. See parameters below:

Parameter NameParameter MeaningTypeRequired
reportingToTencentSdkReport events to Tencent. Required if Tencent Ads SDK is initialized.
1: Full reporting
2: Partial reporting
3: No reporting
numberYes
backFlowDayReactivation cycle (days)numberYes
customProperties/objectNo

Code Example

SESDK.trackReActive({
  reportingToTencentSdk: 1,
  backFlowDay: 7,
  customProperties: {
    one: '1',
  }
})

9) Add Mini Game to Wishlist

       Triggered when a user adds a Mini Game to their wishlist, including adding to favorites, adding to "My Mini Games," adding to the home screen, or any custom wishlist logic defined by developers. The _event_name is _mpAddToWishlist.

SESDK.trackAddToWishlist(data)

data: object. See parameters below:

Parameter NameParameter MeaningTypeRequired
reportingToTencentSdkReport events to Tencent. Required if Tencent Ads SDK is initialized. 1: Full reporting 2: Partial reporting 3: No reportingnumberYes
addToWishlistTypeWishlist Type (Enum values):
· Regular Favorite (default)
· Add to My Mini Programs (my)
· Add to Home Screen (desktop)
· Others (others)
stringYes
customProperties/objectNo

Code Example

SESDK.trackAddToWishlist({
  reportingToTencentSdk: 1,
  addToWishlistType: 'default',
  customProperties: {
    one: '1',
  }
})

10) Share Mini Game

       Triggered when a user shares a Mini Game. Distinguish between "Share to Friend" and "Share to Moments." The _event_name is _mpShare.

SESDK.trackShare(data)

data: object. See parameters below:

Parameter NameParameter MeaningTypeRequired
reportingToTencentSdkReport events to Tencent. Required if Tencent Ads SDK is initialized.
1: Full reporting
2: Partial reporting
3: No reporting
numberYes
mpShareTargetShare Type (Enum values):
· Forward to Friend (APP_MESSAGE)
· Share to Moments (TIME_LINE)
stringYes
customProperties/objectNo

Code Example

// 1、Share to Friend 
wx.onShareAppMessage(() => {
  // sdk.track('SHARE', {
  //   target: 'APP_MESSAGE'
  // });
  SESDK.trackShare({
      reportingToTencentSdk: 1,
      mpShareTarget: 'APP_MESSAGE',
      customProperties: {
        one: '1',
      }
  })
});

// 2、Share to Moments
wx.onShareTimeline(() => {
  // sdk.track('SHARE', {
  //   target: 'TIME_LINE'
  // });
  SESDK.trackShare({
      reportingToTencentSdk: 1,
      mpShareTarget: 'TIME_LINE',
      customProperties: {
        one: '1',
      }
  })
});

// 3、Report a share event when it's proactively triggered (report first, then invoke the share interface for higher success rate).
// sdk.track('SHARE', {
//     target: 'APP_MESSAGE'
// });
SESDK.trackShare({
    reportingToTencentSdk: 1,
    mpShareTarget: 'APP_MESSAGE',
    customProperties: {
      one: '1',
    }
})
wx.shareAppMessage();

11) Create Role

       Triggered when a user successfully creates a role in the Mini Game. The _event_name is _mpCreateRole.

SESDK.trackCreateRole(data)

data: object. See parameters below:

Parameter NameParameter MeaningTypeRequired
reportingToTencentSdkReport events to Tencent. Required if Tencent Ads SDK is initialized.
1: Full reporting
2: Partial reporting
3: No reporting
numberYes
mpRoleNameRole NamestringYes
customProperties/objectNo

Code Example

SESDK.trackCreateRole({
  reportingToTencentSdk: 1,
  mpRoleName: 'Role Name',
  customProperties: {
          one: '1',
        }
})

12) Tutorial Finish

       Triggered when a user completes the game's new user tutorial. The _event_name is _mpTutorialFinish.

SESDK.trackTutorialFinish(data)

data: object. See parameters below:

Parameter NameParameter MeaningTypeRequired
reportingToTencentSdkReport events to Tencent. Required if Tencent Ads SDK is initialized.
1: Full reporting
2: Partial reporting
3: No reporting
numberYes
customProperties/objectNo

Code Example

SESDK.trackTutorialFinish({
  reportingToTencentSdk: 1,
  customProperties: { 
  one: '1',
   }
})

13) Update Level

       Triggered when a user levels up in the Mini Game. The _event_name is _mpUpdateLevel.

SESDK.trackTutorialFinish(data)

data: object. See parameters below:

Parameter NameParameter MeaningTypeRequired
reportingToTencentSdkReport events to Tencent. Required if Tencent Ads SDK is initialized.
1: Full reporting
2: Partial reporting
3: No reporting
numberYes
beforeUpgradeLevel before upgradenumberYes
afterUpgradeLevel after upgradenumberYes
customProperties/objectNo

Code Example

SESDK.trackUpdateLevel({
  reportingToTencentSdk: 1,
  beforeUpgrade:1,
  afterUpgrade:2,
  customProperties: {
    one: '1',
  }
})

14) View Mall

       Triggered when a user browses the in-game mall page. The _event_name is _mpViewContentMall.

SESDK.trackViewContentMall(data)

data: object. See parameters below:

Parameter NameParameter MeaningTypeRequired
reportingToTencentSdkReport events to Tencent. Required if Tencent Ads SDK is initialized.
1: Full reporting
2: Partial reporting
3: No reporting
numberYes
customProperties/objectNo

Code Example

SESDK.trackViewContentMall({
  reportingToTencentSdk: 1,
  customProperties: {
    one: '1',
  }
})

15) View Activity

       Triggered when a user browses the in-game activity page. The _event_name is _mpViewContentActivity.

SESDK.trackViewContentActivity(data)

data: object. See parameters below:

Parameter NameParameter MeaningTypeRequired
reportingToTencentSdkReport events to Tencent. Required if Tencent Ads SDK is initialized.
1: Full reporting
2: Partial reporting
3: No reporting  
numberYes
customProperties/objectNo

Code Example

SESDK.trackViewContentActivity({
  reportingToTencentSdk: 1,
  customProperties: {
    one: '1',
  }
})


4.3. Custom Events

       In addition to the clearly predefined events listed above, developers can report custom events according to their own analysis needs.

       Developers should name the custom events following the guide below:

  • String type
  • Start with letters only.
  • No more than 40 characters.
  • Contain numbers, lowercase letters and underscores only.

Code Example:

SESDK.track('test', {
  one: '1',
});

4.4. Custom Properties

       A custom property is an Object where each key-value represents a property.

Key: Property Name

  • String type
  • Start with letters only.
  • No more than 40 characters.
  • Contain numbers, lowercase letters and underscores only.

Value: Property Value

  • Support data types like string, number, boolean, and array
  • For elements of an array, only string type is supported.
  • For other types, they will be forcibly converted to strings and stored.

Custom Property Types

       The data type of custom event properties is determined by their data types reported for the first time and cannot be changed once confirmed. For subsequent reporting of the same properties, only properties with the same data types as the first time will be stored in the database.

Data TypeDescriptionExample
numberRange from -9E15 to 9E15, without quotation marks.1234, 12.34
stringLimit 2KB. Numbers with quotation marks will also be identified as strings."dashen", "北京", "1234", "true"
date"yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd HH:mm:ss", or "yyyy-MM-dd 00:00:00""2023-03-01 12:34:56","2023-03-01 12:34:56.789","2023-03-01 00:00:00"
booleanTrue or false without quotation marks.true, false
arrayAll elements in an array will be converted into strings.["a","1","true"]

Note:

  The data type of the property determines their analysis logic available in analysis models. For example, the numerical type can perform calculations such as maximum value, minimum value, and sum, while the Boolean type can perform calculations of true and false values. Therefore, when determining the format of data reporting, you need to consider the analysis scenarios and business needs and formulate a complete event tracking plan as directions.

4.5. Duration Events

       If you need to record the duration of an event, call the eventStart(eventName) to start timing, and configure the event namet. When the event comes to an end, you need to call eventFinish(event name, data), and a "_duration" property will automatically be added for this event (unit: millisecond). It should be noted that there can only be one timing task for the same event.

SESDK.eventFinish('testEvent', {
  one: '1',
});

       When reporting the preset event _appEnd, the SDK will automatically report the duration timed from the previous _appStart. In other words, you do not need to manually configure the start time for the exit event; the duration will be assigned by default.


5. Set User Property

SolarEngine provides multiple methods for reporting user properties. You can use these methods to add or modify user properties.

It is recommended for you to select properties that change infrequently or hold significant value, for example, age, game level, location, first payment time and total payment amount. Other properties with higher change frequency can be reported and recorded through events.

User property settings can be set by calling userUpdate, userInit, userAdd, userUnset, userAppend, or userDelete.

Note:

      The format requirements of user properties are consistent with those of event properties.

5.1. userInit

       If you want to upload a batch of user attributes, among which the existing user attributes will not update their values, and the non-existing attributes will be created and saved, you can call userInit to set them.

Code Example

SESDK.userInit({
  regtime: "2021-03-01 12:34:56.789", // cusom property
  rolename: "engineer", // cusom property
  age: 29, // cusom property
});

5.2. userUpdate

       For general user attributes, you can call userUpdate to set them. The attributes uploaded in this way will overwrite the original attribute values. If the user attribute does not exist before, it will be created, and the data type will follow the value passed in.

Code Example

SESDK.userUpdate({
  rolename: "leader", // cusom property
});

5.3. userAdd

       If you want to report a numeric attribute and accumulate its values, you can call userAdd. If the attribute has not been set, it will be assigned a value of 0 and then calculated. You can pass in a negative value, which is equivalent to a subtraction operation.

Code Example

SESDK.userAdd({
  age: 1, // cusom property
});

Note:

  The value called by userAdd only allows Number type.

5.4. userUnset

       When you want to clear the user attribute values of a user, you can call userUnset to clear the specified attributes (string array). If the attribute has not been created in the array, the attribute will not be created.

Code Example

SESDK.userUnset(["age"]);

       The parameter passed in by userUnset is the attribute name of the user attribute, and the type is a string array.

5.5. userAppend

       You can call userAppend to append user attributes of array type. If the attribute does not exist, it will be created.

Code Example

SESDK.userAppend({
  location: ["BeiJing"], // cusom property
});

5.6. userDelete

       You can call userDelete to delete users. After a user is deleted, you will no longer be able to query the user's user attributes, but the events generated by the user can still be queried.

Code Example

SESDK.userDelete(deleteType);

// Delete user by AccountId
SESDK.userDelete('userDeleteByAccountId'); 

// Delete user by VisitorId
SESDK.userDelete('userDeleteByVisitorId');
Parameter NameParameter TypeRequired
deleteTypeuserDeleteByAccountId:  Delete a user by Account ID userDeleteByVisitorId:  Delete a user by Visitor IDYes


6. Channel SDK Compatibility Guide

6.1. Tencent Ads

  • Overview: After integrating the SE_SDK, you need to introduce the Tencent Ads SDK. Once you complete the SE initialization method, the system will automatically trigger the initialization of Tencent Ads SDK. When you report key events such as registration and purchase, the system will automatically send this event information to Tencent Ads based on your configuration to complete attribution analysis and data postback.
  • Operation Overview:
  1. Load the Tencent Mini Game Ads SDK: import { SDK } from './dn-sdk-minigame/index.js';
  2. Pass the Tencent Ads SDK to SE (tencentAdvertisingGameSDK)
  3. Enable initialization of the Tencent Ads SDK (isInitTencentAdvertisingGameSDK)
  4. Fill in the necessary parameters for initializing the Tencent Ads SDK (tencentAdvertisingGameSDKInitParams)
  5. Select the data type for the current event to be reported to Tencent (reportingToTencentSdk).
  6. In the initialization method, add new parameters to the Config (see code example in 3.1 SDK Initialization)
ParameterTypeRequiredDescription
isInitTencentAdvertisingGameSDKbooleanNoWhether to initialize the Tencent Mini Game Ads SDK. Default is false.
tencentAdvertisingGameSDKfunctionNoThe reference class for the Tencent Mini Game Ads SDK. Download it by referring to the Tencent Mini Game Ads SDK Integration Document.
reportingToTencentSdknumberNoWhether to report the launch event to Tencent. Default is 3.
1: Report all to Tencent
2: Report partially to Tencent
3: Do not report to Tencent
tencentAdvertisingGameSDKInitParamstencentSDKInitParamsNoRequired parameters for initializing the Tencent Mini Game Ads SDK.
tencentSdkIsAutoTrackbooleanNoWhether the Tencent SDK automatically collects data. Default is true.


tencentSDKInitParams Parameter Description:

ParameterTypeRequiredDescription
user_action_set_idnumberYesData source ID
secret_keystringYesEncryption key
appidstringYesWeChat Mini Game APPID, starts with wx


    • You can set the configuration field "reportingToTencentSdk" individually for the "Launch Event" and "each pre-defined event". The following is the list of currently supported pre-defined events:
      • 4.2.3 In-App Purchase
      • 4.2.6 Registration
      • 4.2.8 Reactivation
      • 4.2.9 Add to Wishlist
      • 4.2.10 Share Mini Game
      • 4.2.11 Create Role
      • 4.2.12 Tutorial Finish
      • 4.2.13 Update Level
      • 4.2.14 View Mall
      • 4.2.15 View Activity
      • Note: It is recommended to actively report the above events.
    • You can configure the "reportingToTencentSdk" field individually for each event as needed to achieve more granular control and data postback.
    • reportingToTencentSdk Field Description:
      • Option 1 (Recommended): Tencent Ads is responsible for attribution matching, and all user event information will be reported back to Tencent Ads. Please configure the field reportingToTencentSdk to 1.
      • Option 2: SolarEngine is responsible for attribution matching, and only users attributed to Tencent Ads will be reported back to Tencent Ads. Please configure the field reportingToTencentSdk to 2.【Note: After Tencent Ads API attribution is discontinued, attribution via SolarEngine will no longer be possible. Please use Option 1 then.】
      • Option 3 (Not Recommended): SolarEngine is responsible for attribution matching, but user information is not reported back to Tencent Ads. Please configure the field reportingToTencentSdk to 3.
      • Note: Channels other than Tencent Ads are still attributed and matched by SolarEngine, and events are reported back via API. No additional SDK configurations needed.
  • Get Tencent Ads SDK Instance
      • If you need to track more events besides the pre-defined events listed above, you can call the interface to get the Tencent Ads SDK instance and call its native reporting methods.
    • Precautions:
      • For scenarios already covered by pre-defined events, it is forbidden to call the Tencent Ads SDK's same-name reporting interface again to avoid data anomalies for the same event.
      • When calling the Tencent Ads SDK for custom events, it is recommended to simultaneously report the SESDK custom event to keep the event data on both ends aligned as much as possible.

Code Example

// Call after SE SDK initialization

// Get Tencent Ads SDK instance
const tencentSdk = SESDK.getTencentAdvertisingGameSDK();

if (tencentSdk) {
  // Report custom Tencent events not covered by SE SDK
  tencentSdk.track('CUSTOM_EVENT', {
    customKey: 'customValue',
  });
}
  • Q&A
    • How to determine if an event was successfully reported to Tencent?

      You can check the return value of the interface https://api.datanexus.qq.com/data-nexus-cgi/miniprogram

      code=0 means success.




Changelog

2026-07-20 1.3.5

  • Event reporting logic optimization

2026-02-02 1.3.2

  • Event reporting logic optimization

2025-03-14 1.3.0

  • Event reporting logic optimization

2025-03-13 1.2.9

  • Event reporting logic optimization

2025-02-13 1.2.8

  • Fixed error when integrating Tencent Ads SDK

2025-01-03 1.2.7

  • Payment event reporting optimization

2024-12-31 1.2.6

  • Internal initialization logic optimization

2024-12-10 1.2.4

  • Compatible with CocosCreator platform compilation and build

2024-11-29 1.2.3

  • Added support for Tencent Ads Mini Games
  • Attribution data result structure adjustment

2024-11-11 1.2.2

  • Optimized event reporting logic

2024-10-31 1.2.1

  • Added SDK internal log reporting

2024-08-14 1.1.9

  • The type of the reported scene value _launch_scene was changed from numeric to string

2024-05-22 1.1.8

  • Fixed the issue of the WeChat Mini Game install event being reported multiple times

2024-04-22 1.1.7

  • Optimized event reporting logic

2024-04-16 1.1.6

  • Optimized event reporting logic

2024-04-01 1.1.5

  • Fixed the issue where reported events could not be deleted in extreme scenarios
  • Optimized the trigger timing of the ready hook under Mini Programs

2024-03-15 1.1.4

  • Added new parameters to A/B test requests

2024-03-01 1.1.3

  • Fixed A/B test initialization parameter issue

2024-01-22 1.1.2

  • Fixed internal log reporting issue

2023-12-06 1.1.1

  • Added getDistinct method to get distinct_id and distinct_id_type
  • Added setOnAttributionListener method to set a callback for listening to attribution results
  • Added getAttribution method to actively get attribution result information
  • Added unionid parameter to the init method
  • Added signature verification for event reporting

2023-11-02 1.1.0

  • Supported pre-defined property and custom property settings
  • Supported pre-defined event and custom event reporting
  • Supported user property settings
  • Supported A/B testing plugin
Previous
WeChat Mini Program SDK
Next
Douyin Mini Program SDK
Last modified: 2026-09-20Powered by