The Kongregate Mobile SDK supports a subset of functionality for Unity games targetted at the web and uploaded to Kongregate. The main purpose of this is to allow Kongregate Plus beta games to track user behavior and generate analytics before publishing your mobile game to test markets.

The first thing you should do is integrate follow the instructions for integrating the Kongregate Mobile SDK into your Unity project.

You should then familiarize yourself with the Kongregate Unity API and the Kongregate Javascript API, as you will be using those to initiate purchases among other things.

In general, all of the methods in the Analytics class are supported, along with some of the methods on the Services class. You can also use the Stats method for submitting statistics, and the Mtx class for checking the user’s Kongregate inventory. Kongregate events such as READY will also be fired as normal. All of the methods on the Mobile class are stubbed out.

The Unity web API automatically loads the Kongregate Javascript API behind the scenes, and you can use it as well via Application.ExternalEval and Application.ExternalCall

Kongregate Web Game Setup

You should experiment with the Unity API while your game is still in the preview state. Your producer will set up the various analytics properties for your game and let you know when everything is ready to go.

You do not have to manage Keen/Swrve keys in the client for web builds. While your game is in preview mode, analytics will be sent to a sandbox, and once in beta/production data will automatically be sent to the live projects.

The analytics mode for web games is also handled on the server side. Your producer will set this up properly for you so you do not need to worry about it.

Web GL Setup

Using the WebGL target works using the same interface as the WebPlayer target. However, one additional step is required to load the Kongregate API. The following line must be included under the head tag of the generated index.html file prior to uploading to Kongregate.

<script src='https://cdn1.kongregate.com/javascripts/kongregate_api.js'></script>

To save yourself from having to add this line everytime you build, it’s a good idea to configure a Custom WebGL Template which can always include it.

Unity Code Changes

In order to enable the web API in your Unity game KongregateAPI.Settings.WebEnabled must be set to true before initializing the SDK. This will cause the Kongregate Javascript API to be loaded, and you will receive a READY event when initialization is complete.

Your existing analytics calls such as AddEvent and SetCommonProperties should work as-is with no code changes. However, purchase tracking may need to work differently as you will be making purchases via the Kongregate javascript microtransaction API.

The example KongregateGameObject.cs has been updated with examples of how this can be accomplished:

Dictionary<string,object> fields = new Dictionary<string,object>()
  { "type", "Gold Pack" },
  { "discount_percent", 12.5 },
  { "context_of_offer", "StoreFront"}

// Start the purchase
kongregate.Analytics.StartPurchase("com.kongregate.web.angrybots.t05_hard", 1, fields);

// Use the Javascript API to initiate the purchase. Notice in this flow we call finishPurchase via
// the Javascript API after the purchase is completed by serializing the game fields needed. You
// could also save the game fields into a variable in your Unity script and then call
// kongregate.Analytics.FinishPurchase(...) in the Unity callback as well.
  @"kongregate.mtx.purchaseItems(['com.kongregate.web.angrybots.t05_hard'], function(result){{
      var status = result.success ? 'SUCCESS' : 'FAIL';
      var data = result.success ? '{0}' : '{1}';
      kongregate.analytics.finishPurchase(status, result.purchase_id, data);

      // Fire the callback in the Unity code
      kongregateUnitySupport.getUnityObject().SendMessage('Kongregate', 'OnKredPurchaseResult', status);
, Analytics.toAnalyticEventJSON(getPurchaseFields()), Analytics.toAnalyticEventJSON(fields)));


If you are not seeing events come through, it can be helpful to look at the JavaScript error console, along with the Unity WebPlayer log. Also ensure that you are not making any calls until the Kongregate API READY event has fired.