🃏 Card Game Analytics - Complete Guide
Learn how to track card drafting, balancing, and player choices with Tokebi's analytics platform.
Transform your card game from guesswork to data-driven balancing with comprehensive player behavior insights.
⚠️ Critical Data Structure Requirements
IMPORTANT: You CAN send arrays like ['Fire_Dragon', 'Lightning_Bolt'] to Tokebi, BUT it will be difficult to analyze since the data isn't unpacked into individual fields.
❌ Works But Difficult to Analyze
// This works but makes analysis harder
Tokebi.track('draft_options_presented', {
cards_available: ['Fire_Dragon', 'Lightning_Bolt', 'Healing_Potion']
});
// Problem: You can't easily create charts comparing individual cards✅ Better - Unpacked for Easy Analysis
// This structure makes analytics much easier
Tokebi.track('draft_options_presented', {
pack_id: 'pack_123',
card_option_1: 'Fire_Dragon',
card_option_2: 'Lightning_Bolt',
card_option_3: 'Healing_Potion',
total_options: 3
});
// Benefit: Now you can easily create charts for each card individually📋 How to Structure Events - Step by Step
Event Structure Thinking Process
1. What happened?
This becomes your event_name
2. Who & When?
Add player info and timing fields
3. Context & Choices
Add situational data and what options were available
Example: Player Drafts a Card
What happened? → 'card_drafted'
Tokebi.track('card_drafted', {
// WHO: Player info
player_level: 15,
player_id: 'player_123',
// WHEN: Timing info
selection_time_seconds: 8.5,
draft_position: 3, // 3rd pick overall
// WHERE: Context info
pack_id: 'pack_123',
draft_format: 'ranked',
// WHAT: The choice made
card_selected: 'Fire_Dragon',
// OPTIONS: What else was available
card_option_1: 'Fire_Dragon', // ← chosen
card_option_2: 'Lightning_Bolt', // ← not chosen
card_option_3: 'Healing_Potion', // ← not chosen
card_option_4: 'Steel_Sword' // ← not chosen
});🔄 Array Unpacking Code Examples
🎮 GDScript (Godot)
# TokebiCardAnalytics.gd - Autoload script
extends Node
func track_draft_options(pack_id: String, cards_array: Array,
draft_position: int, player_level: int):
var event_data = {
"pack_id": pack_id,
"total_options": cards_array.size(),
"draft_position": draft_position,
"player_level": player_level,
"draft_stage": "early" if draft_position <= 5 else
("mid" if draft_position <= 10 else "late")
}
# Unpack array into individual card_option_X fields
for i in range(cards_array.size()):
event_data["card_option_" + str(i + 1)] = cards_array[i]
Tokebi.track("draft_options_presented", event_data)
func track_card_drafted(pack_id: String, selected_card: String,
rejected_array: Array, draft_position: int,
selection_time: float, player_level: int):
var hesitation_level = "slow"
if selection_time < 3.0:
hesitation_level = "quick"
elif selection_time < 10.0:
hesitation_level = "medium"
var event_data = {
"pack_id": pack_id,
"card_selected": selected_card,
"draft_position": draft_position,
"selection_time_seconds": selection_time,
"player_level": player_level,
"hesitation_level": hesitation_level
}
# Unpack rejected cards into individual fields
for i in range(rejected_array.size()):
event_data["card_rejected_" + str(i + 1)] = rejected_array[i]
Tokebi.track("card_drafted", event_data)🟦 Roblox Lua
-- TokebiCardAnalytics ModuleScript
local TokebiCardAnalytics = {}
function TokebiCardAnalytics.trackDraftOptions(packId, cardsArray,
draftPosition, playerLevel)
local draftStage = "late"
if draftPosition <= 5 then
draftStage = "early"
elseif draftPosition <= 10 then
draftStage = "mid"
end
local eventData = {
pack_id = packId,
total_options = #cardsArray,
draft_position = draftPosition,
player_level = playerLevel,
draft_stage = draftStage
}
-- Unpack array into individual card_option_X fields
for i = 1, #cardsArray do
eventData["card_option_" .. tostring(i)] = cardsArray[i]
end
Tokebi:track("draft_options_presented", eventData)
end
function TokebiCardAnalytics.trackCardDrafted(packId, selectedCard,
rejectedArray, draftPosition,
selectionTime, playerLevel)
local hesitationLevel = "slow"
if selectionTime < 3 then
hesitationLevel = "quick"
elseif selectionTime < 10 then
hesitationLevel = "medium"
end
local eventData = {
pack_id = packId,
card_selected = selectedCard,
draft_position = draftPosition,
selection_time_seconds = selectionTime,
player_level = playerLevel,
hesitation_level = hesitationLevel
}
-- Unpack rejected cards into individual fields
for i = 1, #rejectedArray do
eventData["card_rejected_" .. tostring(i)] = rejectedArray[i]
end
Tokebi:track("card_drafted", eventData)
end
return TokebiCardAnalytics⚡ C# (Unity/GameMaker)
using System.Collections.Generic;
public class TokebiCardAnalytics
{
public static void TrackDraftOptions(string packId, string[] cards,
int draftPosition, int playerLevel)
{
string draftStage = draftPosition <= 5 ? "early" :
draftPosition <= 10 ? "mid" : "late";
var eventData = new Dictionary<string, object>
{
["pack_id"] = packId,
["total_options"] = cards.Length,
["draft_position"] = draftPosition,
["player_level"] = playerLevel,
["draft_stage"] = draftStage
};
// Unpack array into individual card_option_X fields
for (int i = 0; i < cards.Length; i++)
{
eventData[$"card_option_{i + 1}"] = cards[i];
}
Tokebi.track("draft_options_presented", eventData);
}
public static void TrackCardDrafted(string packId, string selectedCard,
string[] rejected, int draftPosition,
float selectionTime, int playerLevel)
{
string hesitationLevel = selectionTime < 3f ? "quick" :
selectionTime < 10f ? "medium" : "slow";
var eventData = new Dictionary<string, object>
{
["pack_id"] = packId,
["card_selected"] = selectedCard,
["draft_position"] = draftPosition,
["selection_time_seconds"] = selectionTime,
["player_level"] = playerLevel,
["hesitation_level"] = hesitationLevel
};
// Unpack rejected cards into individual fields
for (int i = 0; i < rejected.Length; i++)
{
eventData[$"card_rejected_{i + 1}"] = rejected[i];
}
Tokebi.track("card_drafted", eventData);
}
}🎯 GML (GameMaker Studio)
// Script: track_draft_options(pack_id, cards_list, draft_position, player_level)
var event_data = ds_map_create();
ds_map_add(event_data, "pack_id", argument0);
ds_map_add(event_data, "total_options", ds_list_size(argument1));
ds_map_add(event_data, "draft_position", argument2);
ds_map_add(event_data, "player_level", argument3);
// Add draft stage
var stage = "late";
if (argument2 <= 5) stage = "early";
else if (argument2 <= 10) stage = "mid";
ds_map_add(event_data, "draft_stage", stage);
// Unpack list into individual card_option_X fields
for (var i = 0; i < ds_list_size(argument1); i++) {
var field_name = "card_option_" + string(i + 1);
var card_name = ds_list_find_value(argument1, i);
ds_map_add(event_data, field_name, card_name);
}
tokebi_track("draft_options_presented", event_data);
ds_map_destroy(event_data);
// Usage example
var cards_available = ds_list_create();
ds_list_add(cards_available, "Fire_Dragon", "Lightning_Bolt",
"Healing_Potion", "Steel_Sword");
track_draft_options("pack_123", cards_available, 3, 15);
ds_list_destroy(cards_available);📊 Complete Event Structure for Card Games
Core Draft Events
// 1. When pack opens and cards are shown
Tokebi.track('draft_pack_opened', {
pack_id: 'pack_123',
pack_number: 1, // 1st, 2nd, 3rd pack
pack_type: 'basic', // basic/premium/legendary
player_level: 15,
draft_format: 'ranked' // ranked/casual/tournament
});
// 2. When options are presented (unpacked for easy analysis)
Tokebi.track('draft_options_presented', {
pack_id: 'pack_123',
card_option_1: 'Fire_Dragon',
card_option_2: 'Lightning_Bolt',
card_option_3: 'Healing_Potion',
card_option_4: 'Steel_Sword',
total_options: 4,
draft_position: 3,
player_level: 15
});
// 3. When player selects a card
Tokebi.track('card_drafted', {
pack_id: 'pack_123',
card_selected: 'Fire_Dragon',
card_rejected_1: 'Lightning_Bolt',
card_rejected_2: 'Healing_Potion',
card_rejected_3: 'Steel_Sword',
draft_position: 3,
selection_time_seconds: 8.5,
hesitation_level: 'medium', // quick/medium/slow
draft_stage: 'early', // early/mid/late
player_level: 15
});Advanced Event Types
// 4. Deck building decisions (which drafted cards make final deck)
Tokebi.track('deck_finalized', {
total_drafted: 15,
final_deck_size: 30,
cards_cut: 5, // drafted cards that didn't make it
player_level: 15,
// Unpacked final deck cards
deck_card_1: 'Fire_Dragon',
deck_card_1_was_drafted: 'yes', // yes/no
deck_card_2: 'Basic_Land',
deck_card_2_was_drafted: 'no', // added from collection
// ... continue for all deck cards
});
// 5. Mulligan decisions (starting hand choices)
Tokebi.track('mulligan_decision', {
starting_hand_size: 7,
cards_kept_count: 4,
cards_replaced_count: 3,
player_level: 15,
// Unpacked cards
kept_card_1: 'Fire_Dragon',
kept_card_2: 'Lightning_Bolt',
replaced_card_1: 'Healing_Potion',
replaced_card_2: 'Steel_Sword'
});
// 6. Post-game card impact ratings
Tokebi.track('post_game_card_ratings', {
game_outcome: 'victory', // victory/defeat
cards_rated: 8,
player_level: 15,
// Unpacked card ratings
rated_card_1: 'Fire_Dragon',
rated_card_1_impact: 'high', // high/medium/low
rated_card_2: 'Lightning_Bolt',
rated_card_2_impact: 'medium'
});📈 Analytics Dashboard Setup
1. Card Popularity Rankings
Tokebi Feature: Bucketed Analysis
- • Event:
card_drafted - • Group By:
card_selected - • Aggregate:
COUNT - • Sort: Descending (most popular first)
- • Which cards are auto-picks vs never-picked
- • Cards that might need power level adjustments
- • Overall card balance across your set
2. Pick Rate by Draft Position
Tokebi Feature: Cross-tabulation Analysis
- • Event:
card_drafted - • X-Axis:
card_selected - • Group By:
draft_stage(early/mid/late) - • Value: Pick rate percentage
- • Which cards are "first pick" cards vs "late pick" cards
- • Whether card power levels match draft positions
- • Cards that are undervalued/overvalued
3. Decision Time Analysis
Tokebi Feature: Bucketed Analysis
- • Event:
card_drafted - • Group By:
card_selected - • Aggregate:
AVERAGEofselection_time_seconds - • Sort: Descending (longest decision time first)
- • Cards with unclear power levels (cause hesitation)
- • Cards needing better descriptions or clarity
- • Decision complexity indicators
4. Draft-to-Deck Conversion Rate
Tokebi Feature: Bucketed Analysis
- • Event:
deck_finalized - • Analysis: Cards with
_was_drafted: 'yes' - • Metric: % of drafted cards that make final decks
- • Which drafted cards actually get used
- • Cards that are "draft traps" vs "deck staples"
- • True card value beyond popularity
🔧 Troubleshooting
What to do if events aren't appearing in Tokebi
1. Check Event Names
// ❌ Wrong: Inconsistent naming
Tokebi.track('cardDrafted', {...});
Tokebi.track('card_selected', {...});
// ✅ Right: Consistent snake_case
Tokebi.track('card_drafted', {...});
Tokebi.track('card_drafted', {...});2. Verify API Key Configuration
- • Ensure your Tokebi API key is set correctly
- • Check if you're in development vs production mode
- • Confirm network connectivity
3. Check Data Types
// ❌ Wrong: Sending undefined values
Tokebi.track('card_drafted', {
card_selected: undefined, // This might cause issues
player_level: "15" // String instead of number
});
// ✅ Right: Clean data types
Tokebi.track('card_drafted', {
card_selected: 'Fire_Dragon',
player_level: 15
});How to verify your array unpacking is working
1. Add Debug Logging
function trackCardDrafted(packId, selectedCard, rejectedArray) {
const eventData = { /* your event data */ };
// Debug: Log the event data before sending
console.log('Sending to Tokebi:', eventData);
Tokebi.track('card_drafted', eventData);
}2. Test with Simple Data First
// Test with just 2 cards to make sure unpacking works
const simpleTest = ['Card_A', 'Card_B'];
trackDraftOptions('test_pack', simpleTest, 1, 1);
// Check if you see: card_option_1: 'Card_A',
// card_option_2: 'Card_B' in Tokebi3. Verify Field Names in Tokebi Dashboard
- • Look for your events in Tokebi's event explorer
- • Check that you see individual
card_option_1,card_option_2fields - • If you only see array data, your unpacking isn't working
Common Data Structure Mistakes
❌ Mixing Array and Individual Fields
// Wrong: Don't mix these approaches
Tokebi.track('card_drafted', {
cards_available: ['Fire_Dragon', 'Lightning_Bolt'], // Array
card_option_1: 'Fire_Dragon' // Individual
});✅ Consistent Individual Fields
// Right: Use one approach consistently
Tokebi.track('card_drafted', {
card_option_1: 'Fire_Dragon',
card_option_2: 'Lightning_Bolt'
});❌ Inconsistent Field Naming
// Wrong: Mixed naming conventions
Tokebi.track('card_drafted', {
cardSelected: 'Fire_Dragon', // camelCase
card_rejected_1: 'Lightning_Bolt', // snake_case
'card-option-1': 'Steel_Sword' // kebab-case
});✅ Consistent snake_case
// Right: Consistent snake_case
Tokebi.track('card_drafted', {
card_selected: 'Fire_Dragon',
card_rejected_1: 'Lightning_Bolt',
card_option_1: 'Steel_Sword'
});🚀 Quick Start Checklist
Implementation Steps
- 1. Add Core Events - Start with
draft_options_presentedandcard_draftedevents - 2. Implement Array Unpacking Functions - Use the for loop examples above
- 3. Test Your Events - Make sure individual fields appear in Tokebi
- 4. Debug with Logging - Add console.log to verify event structure
- 5. Create First Chart - Basic card popularity column chart
- 6. Add Advanced Events - Deck building, mulligan, impact ratings
- 7. Build Complex Analytics - Draft-to-deck conversion, impact analysis
- 8. Set Review Schedule - Weekly balance analysis meetings
Why Array Unpacking Matters
With Arrays (Harder to Analyze)
You can't easily create a chart showing "How often is Lightning_Bolt picked when it's an option?"
With Unpacked Fields (Easy to Analyze)
Now you can easily filter and chart individual card performance across all scenarios!
🃏 Ready to Balance Your Card Game?
Remember: You CAN send arrays to Tokebi, but unpacking them into individual fields makes creating useful analytics dashboards much easier!