Skip to content

Getting Started

Gravitum edited this page Jan 22, 2017 · 30 revisions

Gravitum is a high volume and reliable player retention platform for mobile applications. We support all major native and mobile platforms by providing dedicated SDKs for each platform. And an online dashboard for analytics monitoring and push campaigns flow setup.

Platform Specific Configuration

  • If you will be releasing your game on Android platform, follow this guide to set up the required settings in Google Play Developer Console.

  • If you will be releasing your game on iOS platform, follow this guide to set up the required settings in the Apple Developer Console.

SDK Installation

Start with the latest Unity package import. Open your Unity project, then double click on the downloaded unitypackage file for the version of Unity you're using. The following import package screen will come up. Press Import.

screen1.png

The second step is to provide basic settings to Gravitum Settings. Open Gravitum Settings by pressing menu Window -> Gravitum -> Edit Settings in your Unity editor. You have to provide Google Cloud Messaging Sender Id for Android platform.

screen4.png

You can find the App Token and App Secret in your Gravitum Developer Dashboard. Sender ID you can find in your Google Play Developer Console (more information here).

Now you are ready to start programming.

Programming guidelines

In the first scene that is loaded when your game is opened, add the following code to an object that is enabled in the scene. You can create a new Script file or add it to an existing Script like your own GameController or TitleScreenController that you may have already created.

void Start () {
    Gravitum.Analytics.SetUserId(user_id);
    Gravitum.Analytics.SetUserName(user_name);
    Gravitum.Analytics.SetFacebookId(facebookId);
    Gravitum.Analytics.SetDevicePushToken(gcmId);
    Gravitum.Analytics.SetGender(Gravitum.Analytics.Gender.Male);
    Gravitum.Analytics.SetBirthday(new System.DateTime(1985, 5, 16, 0, 0, 0, 0, System.DateTimeKind.Utc));

    Dictionary<string, object> properties = new Dictionary<string, object> ();
    properties.Add ("playerProperty1", "Ginger");
    properties.Add ("playerProperty2", 36);
    Gravitum.Analytics.SetCustomProperties (properties);
    
    Gravitum.Analytics.Init ();
}

Important: All the method calls before Gravitum.Analytics.Init are optional methods. These methods used to set additional user metadata. Let's take a brief review of the optional methods.

  • The very first optional method is SetUserId. You may provide your own user id in certain cases (e.g. you want to use Google Play Services/Game Center player id as the unique user id for Gravitum service or you have your own web server with the custom player authentication), otherwise, it will be generated automatically. Just make sure, that the Id you provide will be unique for each user.

  • To provide the user name use SetUserName method with the string name. Unlike the used Id, user name may not be unique. What name to provide is up to you without any restrictions.

  • Set user Facebook Id via SetFacebookId method call. The common approach if to get the user Facebook Id from Facebook SDK itself and provide it to Gravitum Analytics.

  • If you have your own push notifications service implementation, you may use SetDevicePushToken method to provide the unique Id for each user device. If you don't pass any particular token, the Gravitum will generate push token by itself according to the Google Cloud Messaging SenderId you provided with the Init method.

  • Last two SetBirthday and SetGender speak for themselves. Provide the user birthday via System.DateTime object and user gender via Gravitum.Analytics.Gender enum.

  • You can set custom unique fields for each user. This fields will be used for filtering the segments from the audience of your application. Important: You can set up to 15 custom fields for each user.

Now we are done with SDK initialization and are ready to setup events tracking.

To send custom event use following code sample. You can provide any event data you want as a Dictionary. What data to send with analytics event depends on your game project. It is important that you think through the types of events you want to send up and the structure of the data associated with each event.

//Example 1: Send a Generic test event "GenericTest"
Dictionary<string, object> eventData = new Dictionary<string, object> ();
eventData.Add ("custom_string_data", "string_data");
eventData.Add ("custom_int_data", 10101);
Gravitum.Analytics.SendEvent ("GenericTest", eventData);

//Example 2: Send player progress data on starting a new game level via a "gameProgress" event type
Dictionary<string, object> gameProgressData = new Dictionary<string, object> ();
gameProgressData.Add ("Action", "Start");
gameProgressData.Add ("Level", currentLevel);
Gravitum.Analytics.SendEvent ("gameProgress", gameProgressData);

One more specific Analytics event type is Monetary event. The common approach is to track In-App Purchases with this event. Please send this event for every successful In-App Purchase, provide the product Id, price and the currency code of the real In-App Purchase. All these events are colected and presented in the Purchases section of the Gravitum Dashboard.

Gravitum.Analytics.SendMonetaryEvent("coins", 0.99f, "USD");

Important: You shouldn't send any event for tracking session length. All the duration tracking events will be sent under the hood. Game session metrics are available on your Gravitum Developer Dashboard.

If you need more detailed information about each API, you can find all the SDK API References here.

Integration Testing

The next step is to test that the SDK is sending data up to our server. The Gravitum SDK comes with a test scene to test successful integration. Next Step: Sample Scene

Clone this wiki locally