« SDKBOX Home

SDKBOX GUI Plugin for Cocos Creator

How to integrate SDKBox Plugin to Cocos Creator project with gui plugin


Environment

Before you start, make sure you have CocosCreator

Download sdkbox gui creator plugin

download SDKBox GUI plugin file, here it's name is sdkbox-1.4.1.zip

Create Project

create a empty creator project, named it SDKBoxSampleGA

Install SDKBox GUI

if you don't have SDKBox GUI, please take a look at this to install.

and here we show a manual way to install following:

install locall, available for one project

install global, available for all project

NOTE:

Install SDKBox Plugin

Menu->SDKBox->Launch

if you have not build your project, sdkbox windows maybe like this:

build project first

NOTE: make sure Start Scene is not null

SDKBox will prompt a query dialog, you can install sdkbox plugin now or later.

SDKBox import Google Analytics (GA)

Config SDKBox Plugin

edit ./build/jsb-default/res/sdkbox_config.json

{
    "android": {
        "GoogleAnalytics": {
            "trackingCode": "UA-62417901-1"
        }
    },
    "ios": {
        "GoogleAnalytics": {
            "track_init_screen": false,
            "trackingCode": "UA-62417901-1"
        }
    }
}

set trackingCode with your specific Google Analytics Tracking Code account information.

Invoke SDKBox Plugin

create a new script named GA.js and attach to a node, here attach to Canvas

cc.Class({
    extends: cc.Component,

    properties: {
    },

    onLoad: function () {
        if ('undefined' === typeof(sdkbox) || 'undefined' === typeof(sdkbox.PluginGoogleAnalytics)) {
            return;
        }
        sdkbox.PluginGoogleAnalytics.init();
        cc.log('GA init');
    },

    logEvent: function() {
        if ('undefined' === typeof(sdkbox) || 'undefined' === typeof(sdkbox.PluginGoogleAnalytics)) {
            return;
        }
        sdkbox.PluginGoogleAnalytics.logEvent("Test", "Click", "", 1);
        sdkbox.PluginGoogleAnalytics.dispatchHits();
        cc.log('GA log test');
    }
});

add a button to scene, and make click attach to logEvent function

Build Project

Build Project (Shift + Command + B), this will sync new change to jsb-default project

Compile & Run

open ./build/jsb-defalut with Xcode, compile and run.