Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Initializing

Martin Treacy-Schwartz edited this page Mar 15, 2017 · 3 revisions

Call this method to initialize using the game key and secret key for your game.

// Initialize
gameanalytics::GameAnalytics::initialize("[game key]", "[secret key]");

💡
Don't have any keys yet?
Head over here and register your game at the GameAnalytics website!

 

Below is a common example of the code placed in a method lets call it OnStart (which is called at the beginning of the game).

#include "GameAnalytics.h"

// ... other code from your project ...
void OnStart()
{
    // ... other code from your project ...

    gameanalytics::GameAnalytics::setEnabledInfoLog(true);
    gameanalytics::GameAnalytics::setEnabledVerboseLog(true);
    
    gameanalytics::GameAnalytics::configureBuild("0.10");

    {
        std::vector<std::string> list;
        list.push_back("gems");
        list.push_back("gold");
        gameanalytics::GameAnalytics::configureAvailableResourceCurrencies(list);
    }

    {
        std::vector<std::string> list;
        list.push_back("boost");
        list.push_back("lives");
        gameanalytics::GameAnalytics::configureAvailableResourceItemTypes(list);
    }

    {
        std::vector<std::string> list;
        list.push_back("ninja");
        list.push_back("samurai");
        gameanalytics::GameAnalytics::configureAvailableCustomDimensions01(list);
    }

    {
        std::vector<std::string> list;
        list.push_back("whale");
        list.push_back("dolphin");
        gameanalytics::GameAnalytics::configureAvailableCustomDimensions02(list);
    }

    {
        std::vector<std::string> list;
        list.push_back("horde");
        list.push_back("alliance");
        gameanalytics::GameAnalytics::configureAvailableCustomDimensions03(list);
    }

    gameanalytics::GameAnalytics::configureWritablePath("[path_to_save_log_files_at]");
    
    gameanalytics::GameAnalytics::initialize("[game key]", "[secret key]");

    return true;
}

 

NEXT  →

Clone this wiki locally