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
Get the Tokebi plugin from the official Godot Asset Library. Install directly in your project.
View in Asset LibraryWhat'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
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/
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.
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. Go to Project Settings → AutoLoad
- 2. Click the "+" button
- 3. Set Name:
Tokebi - 4. Set Path:
res://tokebi.gd - 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 detectionevent_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
}
# Keep nesting simple (max 2-3 levels)
{
"player_data": {
"stats": {
"nested_info": "this is getting complex"
}
}
}
# Better approach - flatten the structure
{
"player_level": 5,
"player_health": 100,
"player_location": "forest_area"
}🎨 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.gdis 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 = truefor 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.