Code Reference


These steps are for advanced users who want to more closely integrate our API calls with their projects.

By default, CognitiveVR_Manager is Initialized on Start() with the correct settings. You only need to manually initialize the plugin if you are NOT using this prefab.

Use the namespace (optional)
using CognitiveVR;
Initialize the plugin (Simple)
CognitiveVR.InitParams initParams = CognitiveVR.InitParams.create(

CognitiveVR.Core.init(initParams, delegate(CognitiveVR.Error initError) {
Initialize the plugin (Advanced)
CognitiveVR.InitParams initParams = CognitiveVR.InitParams.create(

        CognitiveVR.EntityInfo.createUserInfo("John Smith"),

        CognitiveVR.EntityInfo.createDeviceInfo().setProperty(" SomeDeviceProperty", true)

CognitiveVR.Core.init(initParams, delegate(CognitiveVR.Error initError) {
    if(CognitiveVR.Error.Success == initError)
        Debug.Log("onCognitiveVRInitComplete: " + initError.ToString());
        Debug.LogError("onCognitiveVRInitComplete: " + initError.ToString());    


A Session Transaction should begin from your main menu. It will help contextualize game events and could contain nested transactions (such as "level"). For an explanation about nested transactions, refer to the Transactions page.

Begin a session
End a session

User Info

This can be used to track a user across multiple devices. A user's unique Steam ID is a good value to use as the userID.

CognitiveVR.EntityInfo myNewUser = CognitiveVR.EntityInfo.createUserInfo(
    "John Smith",
    properties: new Dictionary<string, object> {
        { "PremiumUser", true },
        { "SignUpPromotionUsed", "FreeMonthTrial" }

CognitiveVR.Core.registerUser(myNewUser, delegate(CognitiveVR.Error registerError) {});

Device Info

This is sent automatically during Core.Init().


For an explanation about transactions, refer to the Transactions page.

Instant Transaction
CognitiveVR.Instrumentation.Transaction("A Transaction Happened").beginAndEnd();
Begin Extended Transaction
CognitiveVR.Instrumentation.Transaction("Extended Transaction").begin();
End Extended Transaction
CognitiveVR.Instrumentation.Transaction("Extended Transaction").end();
One Transaction Property
CognitiveVR.Instrumentation.Transaction("A Transaction Happened")
    .setProperty("Enemy_Killed", "Wolf")
Multiple Transaction Properties
CognitiveVR.Instrumentation.Transaction("A Transaction Happened")
    .setProperty("Enemy_Killed", "Wolf")
    .setProperty("Powerup", "Super_Speed")
CognitiveVR.Instrumentation.Transaction("An Event Happened")
    .setProperties(new Dictionary<string, object> {
      { "Enemy_Killed", "Wolf" },
      { "Powerup", "Super_Speed" }


Collections can be used to update variables, such as in-game currency

//after the player has bought an item
CognitiveVR.Instrumentation.updateCollection("gems", currentGemCount, -itemCost, true);

Tuning Variables

Tuning variables allow you to adjust your experience based on a segment of your users. Tuning variables are defined in the cognitiveVR Dashboard

if (CognitiveVR.Tuning.getVar<bool>("premium", false))
    Debug.Log(CognitiveVR.Tuning.getVar<float>("welcomeTime", 3.0f));