NOTE: CognitiveVR has been rebranded to Cognitive3D. Code references, methods, menus, and variables remain untouched.

Using the Cognitive3D SDK for Unreal

Welcome! This SDK allows you to integrate your Unreal applications with Cognitive3D, which provides analytics and insights about your project. In addition, Cognitive3D empowers you with the ability to take actions that will improve users' engagement with your experience.

This SDK is in development and many changes should be expected! Stability is the highest priority - please get in touch if you experience any issues.

This plugin has been tested with Unreal verion 4.14.3. If you are using a newer version, please check Troubleshooting. It has only been tested on Windows 10.


Step 1: Sign up

If you have not already done so, please register at https://dashboard.cognitivevr.io.

Step 2: Download the SDK

Our package is available on our Github Release page.

Step 3: Import SDK

These instructions will help you install the C++ API as well as Blueprint nodes

Note

Your Unreal project must be a C++ project. To convert from a Blueprint project, see Troubleshooting

  • Close Unreal
  • Copy the plugins folder into your project root. This is the directory with Binaries, Intermediate and Source folders and YourProjectName.uproject file

root

  • Add these dependencies to Source/YourProjectName/YourProjectName.Build.cs.
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "CognitiveVR"});
PrivateDependencyModuleNames.AddRange(new string[] {"Json","JsonUtilities","CognitiveVR"});
PrivateIncludePathModuleNames.AddRange(new string[] {"CognitiveVR"});
  • Add CognitiveVR header to Source/YourProjectName/YourProjectName.h
#include "Public/CognitiveVR.h"
  • Delete the Binary folder in your project. This will be regenerated
  • Add the following Plugins section to YourProjectName.uproject to enable Analytics Blueprints if they are not yet enabled. You will need to open YourProjectName.uproject with a text editor. This is an example of a completed .uproject file:
{
    "FileVersion": 3,
    "EngineAssociation": "4.14",
    "Category": "",
    "Description": "",
    "Modules": [
        {
            "Name": "YourProjectName",
            "Type": "Runtime",
            "LoadingPhase": "Default"
        }
    ],
    "Plugins": [
        {
            "Name": "AnalyticsBlueprintLibrary",
            "Enabled": true
        }
    ]
}
  • Right-click on YourProjectName.uproject and generate Visual Studio project files
  • When you open your project through the Epic Games Launcher, you will be prompted to recompile your project and the cognitiveVR Plugin

  • If the plugin is loaded correctly, it should be visible in the Plugins window

Plugins Window

Step 4: Get your product ID

After logging in to the website dashboard, select your product and go to the test branch. Highlight and copy the product ID displayed in the address bar.

Product ID

  • Add this section to the bottom of your Config/DefaultEngine.ini. You should replace 'companyname1234-productname-test' with your personal CustomerID;
[Analytics]
ProviderModuleName=CognitiveVR
CognitiveVRApiKey=companyname1234-productname-test

Step 5: Basic Setup

Blueprint

  • Analytics Blueprints should be enabled already. This was done when "AnalyticsBlueprintLibrary" was added to YourProjectName.uproject
  • Open the Blueprint Editor. We recommend initializing cognitiveVR Analytics in the Level Blueprint
  • Set Age, Set Gender, Set UserID must be called before Start Session
  • Start Session will automatically send basic information about the computer
  • Note that Start Session does not immediately connect with the analytics server. If you send Events immediately after Start Session, these Events may not be recorded properly
  • Record Event, Record Event with Attribute, and Record Event with Attributes are for your general gameplay events
  • End Session is recommended but not required

Blueprint Startup

Blueprint Events

C++

You can access the analytics from either IAnalyticsProvide methods or FAnalyticsProviderCognitiveVR methods. These can be called from anywhere in your project that includes 'YourProjectName.h'.

This is a short example of how to initialize the CognitiveVR Analytics SDK in C++. These steps are based on the Unreal Programming Quickstart. See the Code Reference page for more examples and how to use the API.

From the Content Browser add a C++ class. Call it 'AnalyticsInitExample'. This will generate AnalyticsInitExample.h and AnalyticsInitExample.cpp files. The complete AnalyticsInitExample.h and AnalyticsInitExample.cpp files are shown below

AnalyticsInitExample.h

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "GameFramework/Actor.h"
#include "FloatingActor.generated.h"

UCLASS()
class YOURPROJECTNAME_API AAnalyticsInitExample : public AActor
{
    GENERATED_BODY()

public: 
    // Sets default values for this actor's properties
    AAnalyticsInitExample();

    // Called when the game starts or when spawned
    virtual void BeginPlay() override;
};

AnalyticsInitExample.cpp

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#include "YourProjectName.h"
#include "AnalyticsInitExample.h"

// Sets default values
AAnalyticsInitExample::AAnalyticsInitExample()
{
    // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = false;
}

// Called when the game starts or when spawned
void AAnalyticsInitExample::BeginPlay()
{
    Super::BeginPlay();
    TSharedPtr<IAnalyticsProvider> Analytics = FAnalytics::Get().GetDefaultConfiguredProvider();
    Analytics.Get()->StartSession();
}

Rebuild your project - this may require closing the editor and deleting the Binary folder in you project root. This folder will be regenerated when you launch the editor through the Epic Games Launcher. Make sure you put this AnalyticsInitExample actor into your scene!

Step 6: Send data!

Navigate back to our dashboard and select the ​test​ branch of your product.

Integrations Tab

Integrations Data

Now switch back to your Unreal project and run the scene in the Editor. If you switch back to our dashboard once again, you will see your data start streaming in to our cloud!

Done!

That's it! You are now tracking your user's basic data including engine version, CPU brand, RAM, GPU, HMD and OS