Unity Engine
Unity SDK Setup Guide

Complete setup guide for integrating Tokebi analytics into your Unity projects.

v2.0 batched SDK with 30-second batching, object pooling, and minimal memory allocations for production games.

🚀 Quick Setup Overview

Get analytics running in under 5 minutes! The Tokebi Unity SDK v2.0 provides production-ready analytics with batching.

📦

1. Install

Package Manager or Manual

🔧

2. Setup

Tools → Tokebi → Setup Analytics

📊

3. Track

Start tracking events

📦 Step 1: Installation Methods

🎯 Choose Your Installation Method

Three ways to install the Tokebi Unity SDK v2.0. All methods give you the same production-ready batched SDK.

📦 Method 1: Package Manager (Recommended)

Installation Steps

  1. 1. Open Unity → Window → Package Manager
  2. 2. Click "+" → "Add package from git URL"
  3. 3. Enter: https://github.com/TokebiAcademy/tokebi-metrics-unity-plugin.git
  4. 4. Unity installs automatically
  5. 5. Go to Tools → Tokebi → Setup Analytics to configure

Gets you: v2.0 batched SDK (production-ready)

What You Get

  • • Complete Tokebi SDK for Unity
  • • 30-second event batching
  • • Object pooling for performance
  • • Automatic updates via Package Manager
  • • Built-in editor tools
  • • Multiplayer support
View on GitHub

🔧 Method 2: Manual Installation

1

Download Repository

Download the repository as ZIP or clone it from GitHub

2

Create Folder Structure

Create folders in Unity: Assets/Tokebi/ and Assets/Tokebi/Editor/

3

Copy Files

Runtime/TokebiSDK.cs → Assets/Tokebi/TokebiSDK.cs
Runtime/TokebiSDK.Runtime.asmdef → Assets/Tokebi/TokebiSDK.Runtime.asmdef
Editor/TokebiInstaller.cs → Assets/Tokebi/Editor/TokebiInstaller.cs  
Editor/TokebiMenu.cs → Assets/Tokebi/Editor/TokebiMenu.cs
Editor/TokebiSDK.Editor.asmdef → Assets/Tokebi/Editor/TokebiSDK.Editor.asmdef
4

Setup SDK

Go to GameObject → Tokebi → Create Analytics SDK and set your API key

Gets you: v2.0 batched SDK (production-ready)

📝 Method 3: Via manifest.json

Direct Package Definition

Add the package directly to your Unity project's manifest file for automatic installation.

  1. 1. Close Unity
  2. 2. Open Packages/manifest.json
  3. 3. Add the dependency shown on the right
  4. 4. Save and reopen Unity

manifest.json

{
  "dependencies": {
    "com.tokebi.analytics": "https://github.com/TokebiAcademy/tokebi-metrics-unity-plugin.git#v2.0.0"
  }
}

Gets you: v2.0 batched SDK (production-ready)

⚙️ Step 2: Setup & Configuration

🚀 Quick Setup (Recommended)

Setup Wizard

  1. 1. Go to Tools → Tokebi → Setup Analytics
  2. 2. Enter your API key
  3. 3. Click "Create Analytics GameObject"
  4. 4. Done! 🎉

💡 Tip: The setup wizard automatically creates the GameObject with proper configuration and persistence across scenes.

Manual Setup

  1. 1. Create empty GameObject in your scene
  2. 2. Add TokebiSDK component
  3. 3. Set your API key in the inspector
  4. 4. Done!

ℹ️ Note: Manual setup requires you to manage the GameObject persistence yourself.

🎮 SDK Features & Performance

⚡ v2.0 Performance Features

  • 30-second batching (like Unity Analytics)
  • Minimal memory allocations
  • Object pooling for network requests
  • Console/mobile optimized
  • Automatic player tracking
  • 95%+ reduction in GC pressure

📊 Perfect For

  • • Tracking hundreds of events per minute
  • Mobile games with performance constraints
  • Console games with strict memory limits
  • Multiplayer games with many clients
  • Production games requiring stability
  • • Games needing up to 3600x fewer network requests

📊 Step 3: Basic Usage

🎯 Basic Tracking Syntax

// Basic syntax
TokebiSDK.Instance.Track("event_name", new Dictionary<string, object>
{
    ["key"] = "value"
});

// Simple examples
TokebiSDK.Instance.Track("player_action", new Dictionary<string, object> {
    ["action"] = "jump",
    ["level"] = "1-1",
    ["position_x"] = 10.5f
});

// Convenience methods for common events
TokebiSDK.Instance.TrackLevelStart("level-1");
TokebiSDK.Instance.TrackLevelComplete("level-1", 45.2f);

// The SDK automatically handles:
// - Batching (30-second intervals)
// - Player ID generation and persistence
// - Game ID from registration  
// - Timestamps and platform info
// - Object pooling and memory optimization

event_name

String describing what happened (your choice!)

payload

Dictionary with event-specific data (optional)

🎮 Example Integration

Complete PlayerController Example

public class PlayerController : MonoBehaviour 
{
    private void Start() 
    {
        TokebiSDK.Instance.TrackLevelStart(SceneManager.GetActiveScene().name);
    }
    
    private void OnJump() 
    {
        TokebiSDK.Instance.Track("player_jump", new Dictionary<string, object> {
            ["level"] = SceneManager.GetActiveScene().name,
            ["player_position"] = transform.position.ToString(),
            ["timestamp"] = Time.time
        });
    }
    
    private void OnLevelComplete() 
    {
        TokebiSDK.Instance.TrackLevelComplete(
            SceneManager.GetActiveScene().name, 
            Time.timeSinceLevelLoad
        );
    }
}

🌐 Multiplayer Support

🎯 Smart Multiplayer Handling

The Tokebi SDK includes built-in multiplayer support to prevent duplicate events from multiple clients.

How It Works

  • Host/Server: Tracks all game events
  • Clients: Events blocked by default
  • Manual control: Use SetMultiplayerMode()
  • Override: Force client events when needed

Configuration

// Set multiplayer modes
TokebiSDK.Instance.SetMultiplayerMode(isClient: false); // Host
TokebiSDK.Instance.SetMultiplayerMode(isClient: true);  // Client

🔧 Editor Tools

🛠️ Available Tools

  • Tools → Tokebi → Setup Analytics
    Quick setup wizard
  • Tools → Tokebi → Test Analytics
    Send test event
  • Tools → Tokebi → Force Flush Events
    Send queued events immediately
  • GameObject → Tokebi → Create Analytics SDK
    Add SDK to scene

📋 Requirements

  • Unity 2019.4 or higher
  • Recommended: Unity 2020.3+
  • Tokebi Metrics account
  • API key from your dashboard

💡 Get your account at tokebimetrics.com

🗝️ API Compatibility

📡 Flexible Event Format

The SDK works with both single events and batch events. Your API automatically detects the format.

Single Events

{
  "eventType": "jump", 
  "playerId": "123",
  "level": "1-1",
  "timestamp": 1642123456
}

Batch Events (v2.0)

{
  "events": [
    {
      "eventType": "jump",
      "playerId": "123",
      "timestamp": 1642123456
    },
    {
      "eventType": "collect",
      "playerId": "123", 
      "timestamp": 1642123457
    }
  ]
}

🔧 Troubleshooting

❌ Package Manager Issues

  • • Check your internet connection
  • • Verify the Git URL is correct
  • • Try Window → Package Manager → Refresh
  • • Check Unity Console for error messages

⚠️ SDK Not Tracking

  • • Ensure TokebiSDK GameObject exists in scene
  • • Check API key is set correctly
  • • Verify you're calling Track() after SDK initialization
  • • Use Tools → Tokebi → Test Analytics to verify setup
  • • Check Unity Console for Tokebi log messages

🌐 Multiplayer Issues

  • • Client events are blocked by default (expected behavior)
  • • Use SetMultiplayerMode() to configure host/client roles
  • • Only host/server should track most game events
  • • Use specific client event methods for UI interactions

🎯 You're Ready!

Your Unity project is now equipped with powerful analytics. The v2.0 SDK provides production-ready performance with batching and optimization.

Check your Tokebi dashboard to see events in real-time and explore the Dashboard and Funnel Analytics features.