Cocos Analytics JavaScript SDK Access Documentation

SDK Download

JavaScript SDK supports WeChat mini games. You need to configure it in the backend of the WeChat mini program when using it.

Steps:

  1. Log in to WeChat official platform as an administrator or developer: https://mp.weixin.qq.com/

  2. Select Development Settings in Settings and add the domain name information in Request Legal Domain Name.

  3. Domain name to be configured:

https://logstorage.cocos.com

This domain name is used to obtain and accept statistical information. It is very important that you do not fill it in incorrectly.

Note: The legitimate domain name of the WeChat mini program can be modified up to 5 times a month.

After configuring the secure domain name, check the developer tools to ensure that the configuration takes effect.

Import Files

<script src="https://download.cocos.com/CocosAnalytics/sdk/cocosAnalytics.min.3.0.2.js"></script>

TypeScript declaration file(.d.ts) cocosanalytics.d.ts

Initialization

cocosAnalytics.init({
    appID: "8113",              // game ID
    version: "1.0.0",           // game/app version number
    storeID: "Apple Store",     // distribution channel
    engine: "cocos",            // game engine
});

Under special circumstances (some embedded browsers like mini programs), call onPause and onResume when switching between the front and back of the game, to accurately count the player's game duration data.

cocosAnalytics.onPause(boolean)
cocosAnalytics.onResume(boolean)

Local Debugging

//Enable (disable) local log output
cocosAnalytics.enableDebug(boolean)

results matching ""

    No results matching ""