Godot Engine
Godot SDK Setup Guide

Complete setup guide for integrating Tokebi analytics into your Godot Engine projects.

One-click installer, AutoLoad configuration, and event tracking examples for indie developers.

๐Ÿš€ Quick Setup Overview

Get analytics running in under 5 minutes! The Tokebi Godot SDK provides everything you need.

๐Ÿ“ฆ

1. Download

One-click installer

๐Ÿ”ง

2. Install

Run in Script Editor

๐Ÿ“Š

3. Track

Start tracking events

๐Ÿ“ฆ Step 1: Download & Installation

๐Ÿ“ฅ Download the Installer

Get the Tokebi Installer

Download our one-click installer that automatically sets up the entire SDK for you.

๐Ÿ“ฅ Download Godot Installer

What's Included

  • โ€ข Complete Tokebi SDK for Godot
  • โ€ข Plugin configuration files
  • โ€ข Setup dialog with API key input
  • โ€ข AutoLoad script generation
  • โ€ข Multiplayer support
  • โ€ข Error handling and logging

๐Ÿ”ง Installation Steps

1

Extract and Add to Project

Extract the downloaded file and copy install_tokebi.gd into your Godot project root.

# Your project structure:
res://
โ”œโ”€โ”€ install_tokebi.gd  โ† Add this file here
โ”œโ”€โ”€ project.godot
โ””โ”€โ”€ scenes/
2

Run the Installer

Open the installer in Godot's Script Editor and run it.

๐Ÿ“ Important: Make sure to open install_tokebi.gd in the Script Editor, then press Ctrl+Shift+X or use Script โ†’ Run to execute the installer.

3

Enable the Plugin

Go to Project Settings โ†’ Plugins and enable "Tokebi Analytics SDK".

Project Settings โ†’ Plugins โ†’ Enable "Tokebi Analytics SDK"

โš™๏ธ Step 2: Configuration

๐Ÿ”‘ API Key Setup

Tokebi Setup Dock

After enabling the plugin, you'll see a "Tokebi Setup" dock in the editor.

โœ… Plugin enabled successfully!

Look for the "Tokebi Setup" dock on the left side of the editor.

Enter Your Credentials

Game Name: Auto-detected from project settings

ProjectSettings.get_setting("application/config/name")

API Key: From your Tokebi dashboard

f28c6329-4aff-4c1a-8917-a66c59db5da4

๐Ÿ”„ AutoLoad Setup

Automatic Generation

The installer creates tokebi.gd with your API key and game settings.

# tokebi.gd (automatically generated)
extends Node

const API_KEY = "your-api-key-here"
const ENDPOINT = "https://tokebi-api.vercel.app"

var game_name: String = ""
var game_id: String = ""
var player_id: String = ""

func _ready():
    game_name = ProjectSettings.get_setting(
        "application/config/name", 
        "Unnamed Godot Game"
    )
    _init_tokebi()

Add to AutoLoad

Manually add the generated SDK to your project's AutoLoad:

  1. 1. Go to Project Settings โ†’ AutoLoad
  2. 2. Click the "+" button
  3. 3. Set Name: Tokebi
  4. 4. Set Path: res://tokebi.gd
  5. 5. Click "Add"

๐Ÿ“ Step 3: Basic Usage

๐ŸŽฏ Basic Tracking Syntax

# Basic syntax
Tokebi.track(event_type: String, payload: Dictionary = {})

# Simple examples
Tokebi.track("game_started")
Tokebi.track("level_completed", {"level": 1, "time": 45.2})
Tokebi.track("item_collected", {"item": "sword", "rarity": "epic"})

# The SDK automatically handles:
# - Player ID generation and persistence
# - Game ID from registration
# - Timestamps and platform info
# - Multiplayer mode detection

event_type

String describing what happened (your choice!)

payload

Dictionary with event-specific data (optional)

๐ŸŽฎ Practical Examples

๐Ÿ Game Flow Events

Game Started
# In your main scene's _ready()
func _ready():
    Tokebi.track("game_started", {
        "game_mode": "single_player",
        "difficulty": "normal",
        "version": "1.2.3"
    })
Level Completed
# When player finishes a level
func complete_level(level_num: int, time_taken: float):
    Tokebi.track("level_completed", {
        "level": level_num,
        "completion_time": time_taken,
        "score": player_score,
        "deaths": death_count,
        "collectibles": items_collected
    })

๐Ÿ‘ค Player Events

Player Death
# In your player script
func _on_player_died():
    Tokebi.track("player_died", {
        "cause": "enemy_attack",
        "location": current_area,
        "level": player_level,
        "health_remaining": 0,
        "enemy_type": "goblin"
    })
Item Collected
# When player picks up an item
func collect_item(item_name: String, item_type: String):
    Tokebi.track("item_collected", {
        "item_name": item_name,
        "item_type": item_type,
        "inventory_count": get_inventory_count(),
        "location": get_current_area(),
        "method": "pickup"
    })

๐Ÿ”ง System Events

Settings Changed
# In your settings menu
func _on_setting_changed(setting: String, value):
    Tokebi.track("setting_changed", {
        "setting_name": setting,
        "new_value": str(value),
        "changed_from": "settings_menu"
    })
Error Occurred
# For error tracking
func log_error(error_message: String, context: String):
    Tokebi.track("error_occurred", {
        "error_message": error_message,
        "context": context,
        "platform": OS.get_name(),
        "engine_version": Engine.get_version_info()
    })

๐Ÿ’ฐ Economy Events

Purchase Made
# In your shop system
func purchase_item(item: String, cost: int, currency: String):
    Tokebi.track("item_purchased", {
        "item_name": item,
        "cost": cost,
        "currency_type": currency,
        "shop_category": "weapons",
        "balance_before": get_currency_amount(currency),
        "balance_after": get_currency_amount(currency) - cost
    })
Currency Earned
# When player earns currency
func earn_currency(amount: int, source: String):
    Tokebi.track("currency_earned", {
        "amount": amount,
        "currency_type": "coins",
        "source": source,
        "total_balance": get_total_coins(),
        "earning_method": "quest_reward"
    })

๐ŸŒ Multiplayer Considerations

๐ŸŽฏ Smart Multiplayer Handling

The Tokebi SDK automatically detects multiplayer modes and prevents duplicate events from multiple clients.

Single Player

All events tracked normally

Multiplayer Host

Tracks all game events

Multiplayer Client

Blocked by default (configurable)

โœ… Automatic Detection

# The SDK automatically detects:
func _detect_multiplayer_mode():
    if not multiplayer.has_multiplayer_peer():
        return "Single Player"
    elif multiplayer.is_server():
        return "Multiplayer Host/Server"
    else:
        return "Multiplayer Client"

# Events are automatically filtered:
# - Host/Server: โœ… Tracks events
# - Client: โŒ Blocks events (prevents duplicates)

๐Ÿ”ง Force Client Events

# For client-specific events (UI, local actions)
func _on_ui_button_clicked():
    Tokebi.track_client_event("ui_interaction", {
        "button": "inventory",
        "screen": "main_menu"
    })

# Or use force parameter
func _on_local_event():
    Tokebi.track("local_action", {
        "action": "screenshot_taken"
    }, true)  # force_track = true

โญ Godot SDK Best Practices

โœ… Do This

  • โ€ข Call Tokebi.track() from any script after AutoLoad setup
  • โ€ข Use descriptive event names like "boss_defeated"
  • โ€ข Include context in payload (location, difficulty, time)
  • โ€ข Track both success and failure events
  • โ€ข Use consistent naming conventions (snake_case)
  • โ€ข Let the SDK handle multiplayer automatically
  • โ€ข Track meaningful player progression events
  • โ€ข Use track_client_event() for UI-specific actions

โŒ Avoid This

  • โ€ข Tracking every frame or physics update
  • โ€ข Generic event names like "event" or "action"
  • โ€ข Empty payload dictionaries for important events
  • โ€ข Tracking before AutoLoad initialization
  • โ€ข Forcing client events for game-critical actions
  • โ€ข Including sensitive data in payloads
  • โ€ข Tracking duplicate events from multiple clients
  • โ€ข Using invalid dictionary structures

๐Ÿš€ Advanced Features

๐Ÿ“Š Session Tracking

# Track complete game sessions
extends Node

var session_start_time: float
var areas_visited: Array = []
var actions_performed: int = 0

func _ready():
    session_start_time = Time.get_time_dict_from_system()
    Tokebi.track("session_started", {
        "platform": OS.get_name(),
        "screen_size": get_viewport().get_visible_rect().size,
        "language": OS.get_locale()
    })

func _exit_tree():
    var session_duration = Time.get_time_dict_from_system() - session_start_time
    Tokebi.track("session_ended", {
        "duration_seconds": session_duration,
        "areas_visited": areas_visited,
        "actions_performed": actions_performed,
        "reason": "game_exit"
    })

๐ŸŽฏ Custom Player Events

# Create reusable tracking functions
extends Node

func track_player_progression(level: int, xp: int):
    Tokebi.track("player_level_up", {
        "new_level": level,
        "total_xp": xp,
        "time_played": get_total_playtime(),
        "achievements_unlocked": get_achievement_count()
    })

func track_combat_event(enemy: String, outcome: String):
    Tokebi.track("combat_" + outcome, {
        "enemy_type": enemy,
        "player_level": get_player_level(),
        "weapon_used": get_current_weapon(),
        "damage_dealt": get_damage_dealt(),
        "health_remaining": get_player_health()
    })

โš ๏ธ Error Handling

๐Ÿ›ก๏ธ Built-in Error Protection

The Tokebi SDK includes comprehensive error handling so tracking failures never break your game.

# The SDK automatically handles errors:
func track(event_type: String, payload: Dictionary = {}, force_track: bool = false):
    # All tracking calls are wrapped in try/catch
    # Invalid payloads are logged but don't crash
    # Network failures are handled gracefully
    # Malformed data is sanitized automatically

# You can also add your own error tracking:
func track_error(error_msg: String, context: Dictionary = {}):
    var error_data = {
        "error_message": error_msg,
        "stack_trace": get_stack(),
        "scene": get_tree().current_scene.scene_file_path,
        "platform": OS.get_name(),
        "engine_version": Engine.get_version_info()
    }
    error_data.merge(context)
    Tokebi.track("error_occurred", error_data)

๐Ÿงช Testing and Debugging

โœ… Console Output

# The SDK provides detailed logging:
[Tokebi] Initializing SDK...
[Tokebi] Player ID: player_1642123456_7834
[Tokebi] Mode: Single Player
[Tokebi] Game registered! ID: game_abc123
[Tokebi] Tracking: level_completed
[Tokebi] Event sent successfully

# Check the Output panel in Godot
# for real-time tracking feedback

๐Ÿ” Test Events

# Create a simple test script:
extends Node

func _ready():
    # Wait for SDK to initialize
    await get_tree().create_timer(1.0).timeout
    
    # Test basic tracking
    test_tracking()

func test_tracking():
    print("Testing Tokebi tracking...")
    
    Tokebi.track("test_event", {
        "test_data": "hello world",
        "timestamp": Time.get_time_dict_from_system()
    })
    
    print("Test event sent!")

๐Ÿ—๏ธ Payload Structure Guidelines

โœ… Good Payload Examples

# Simple values
{
  "level": 5,
  "score": 1250,
  "completed": true
}

# Nested dictionaries
{
  "player_stats": {
    "health": 100,
    "mana": 50
  },
  "location": "forest_area"
}

# Arrays
{
  "items_collected": ["sword", "potion", "key"],
  "enemy_types": ["goblin", "orc"]
}

# Mixed types
{
  "success": true,
  "attempts": 3,
  "time_taken": 45.7,
  "bonus_earned": "speed_bonus"
}

โŒ Avoid These Patterns

# Don't include Godot objects
{
  "player_node": player_reference,  # โŒ Objects can't be serialized
  "scene": get_tree().current_scene  # โŒ Complex objects
}

# Don't use functions or callables
{
  "callback": my_function,  # โŒ Functions aren't serializable
  "signal": some_signal     # โŒ Signals aren't data
}

# Avoid overly complex nesting
{
  "data": {
    "level1": {
      "level2": {
        "level3": {
          "too_deep": "hard to analyze"
        }
      }
    }
  }
}

๐ŸŽจ Common Use Cases

๐ŸŽฎ Game Genres

Platformer Games

Track jumps, deaths, level completion, collectibles

RPG Games

Level ups, quest completion, item usage, combat

Puzzle Games

Solutions found, hints used, time per puzzle

Action Games

Enemy defeats, weapon usage, power-ups

๐Ÿ“Š Analytics Goals

Player Retention

Session length, return visits, feature usage

Game Balance

Difficulty spikes, progression rates, drop-offs

User Experience

UI interactions, navigation patterns, preferences

Performance

Load times, frame rates, error tracking

๐Ÿ”ง Troubleshooting

โŒ Plugin Not Appearing

  • โ€ข Make sure you ran the installer script with Ctrl+Shift+X
  • โ€ข Check that addons/tokebi/ folder was created
  • โ€ข Reload the project (Project โ†’ Reload Current Project)
  • โ€ข Verify the installer didn't show any error messages

โš ๏ธ Events Not Tracking

  • โ€ข Ensure tokebi.gd is added to AutoLoad as "Tokebi"
  • โ€ข Check the API key was entered correctly in the setup dock
  • โ€ข Verify you're calling Tokebi.track() after the SDK initializes
  • โ€ข Look for error messages in the Output panel
  • โ€ข Try the test script from the debugging section

๐ŸŒ Multiplayer Issues

  • โ€ข Client events are blocked by default (use track_client_event())
  • โ€ข Only the host/server should track most game events
  • โ€ข Use force_track = true for client-specific actions
  • โ€ข Check multiplayer mode detection in console output

๐ŸŽฏ You're Ready!

Your Godot project is now equipped with powerful analytics. Start tracking events that matter to your game!

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