๐ Game Analytics & FTUE Tracking in Terra Studio
Understanding how players interact with your game is essential to improving design, retention, and progression. Terra Studio supports in-game analytics out of the box via built-in methods integrated with Mixpanel. You donโt need to do any setup โ just call the APIs as needed, and your data will automatically be sent to Mixpanel as structured events.
This guide helps you track game events (like combat stats, level progress) and FTUE (First-Time User Experience) milestones using Terraโs analytics system.
๐ฎ Using PlayerPrefs with Analytics
Terra Studio fully supports Unity's PlayerPrefs
system for persistent local storage โ and this becomes especially powerful when combined with analytics tracking.
In your analytics implementation, PlayerPrefs
acts as the local cache for all analytics strings before theyโre sent to Mixpanel via Terraโs SetGameAnalyticsPrefs()
methods.
This ensures:
Your data is saved even if the game is closed unexpectedly
You can build up longer strings across sessions
You always retain a fallback before transmitting events
โ
What You Can Store
You can store any stringified version of game data using:
Terra Studio internally uses PlayerPrefs
to store:
Game value strings for progression, combat, sessions, FTUE, and more
FTUE milestone arrays (in JSON format)
Any transient data that you want to log incrementally over time
๐ง Why PlayerPrefs Matters in Analytics
When you call:
It pulls data from your locally maintained strings โ most of which are stored and updated using PlayerPrefs
. Without PlayerPrefs
, youโd lose tracking progress on app restarts or session reloads.
โ๏ธ Quick Example
Hereโs how youโd log a gameplay event and ensure it's retained:
By integrating PlayerPrefs
with your analytics logic, you make sure your event data is always:
Persisted across sessions
Trimmed properly to meet limits
Sent when ready
Use it as your local data log and rely on Terra Studioโs analytics API to push it live when the time is right.
๐ฏ How Game Analytics Work in Terra Studio
Terra Studio provides 12 game values to log analytics data. You have access to two built-in methods:
TerraScene.SetGameAnalyticsPrefs()
TerraScene.SetGameAnalyticsPrefs_2()
Each accepts 6 values (strings, up to 256 characters each), allowing you to track up to 12 types of game data simultaneously.
You can think of these values as containers โ use them to store data like level completions, deaths, power-up usage, etc.
๐งญ Step-by-Step Implementation
โ
Step 1: Decide What to Track
Here are examples of what you might want to track:
1
Level progression
2
Combat statistics
3
Resource collection
4
Power-up or item usage
5
Session info
6
Player customization
7โ11
Economy, multiplayer stats, UI, etc.
12
FTUE tracking (fixed)
๐งฉ Step 2: Design a Compact Format
Each value is limited to 256 characters โ use compact formats with delimiters. Examples:
Level Completion:
levelNumber_completionTime_exitType
Combat Stats:
levelNumber_enemyType_killCount
Multiple entries can be chained using ||
:
๐พ Step 3: Store Analytics Variables in Code
๐ง Step 4: Initialize Variables on Startup
๐ ๏ธ Step 5: Record Game Events
Here's how to record level completion data:
๐ก Step 6: Send Data to Mixpanel
๐งช Example: Combat Stats
๐ FTUE (First-Time User Experience) Tracking
FTUE tracks key player milestones during onboarding (e.g., first level completed, first weapon upgrade).
๐ก How It Works
Store FTUE milestones in an integer array
1 = completed, 0 = not completed
Stored in
game_value12
(last value inSetGameAnalyticsPrefs_2
)
๐ง Initialize FTUE Data
๐จ Log FTUE Data
โ๏ธ Optional Helper
๐งช FTUE Tracking Examples
๐ Best Practices
Use clear constants for FTUE milestone indices
Avoid tracking unrelated data in FTUE
Always call
LogFtueAnalytics()
after setting dataHandle FTUE versioning with array resizing
Keep event strings short and meaningful (within 256 chars)
Last updated