How game SDKs work
Add the plugin for your engine and Mode Metrics captures sessions, launches, levels, pauses, quits, crashes, errors, frame rate and the device with no code of your own. Name your own moments with one call each.
| Setting | Value |
|---|---|
| Host | Your project's tracking hostname, such as https://m.example.com, from Setup |
| Key | An ingest key (mpk_) from Keys on the Setup page. Roblox uses a secret key kept in the experience's Secrets. |
| Batches | Up to 50 events every 10 seconds, and at once when the game leaves the screen. Kept on disk, so a quit or a crash loses nothing |
| Retries | With the same event ids, so nothing is counted twice |
Every engine sends the same event names, so one funnel or one retention report reads a game built in any of them, and the same names as your site and apps where the idea is the same.
Mode serves its SDKs itself, not from an engine's asset store. A published version never changes, and every file and its SHA-256 is listed in SHA256SUMS. Each engine's section has its download and checksum.
What is captured by itself
Each of these has a switch in the plugin's settings.
| Event | When |
|---|---|
$app_installed, $app_updated | The first launch on a device, and the first launch of a new version |
$app_opened | Every launch, with the time to the first frame, and every return to the game |
$app_backgrounded, $app_quit | The game left the screen, or quit |
$screen | A scene, map or level became current, with its load time |
$game_paused, $game_resumed | The engine's own pause |
$game_performance | Every minute, frame rate, frame time percentiles, slow and frozen frames, memory |
$exception | Script and engine errors, each sent once and then at most once a minute, and a crash of the last run, sent on the next launch |
The device goes with the first event of each session. The system, model, processor, memory, graphics card and API, screen density and refresh rate. Never the device's name or a hardware id.
Levels, scores and purchases
One call each, the same in every engine. Attempts and durations are kept for you.
| Call | Event | Sent with |
|---|---|---|
level_start | $level_start | level, attempt |
level_complete | $level_complete | level, attempt, duration_ms, score |
level_fail | $level_fail | level, attempt, duration_ms, reason, score |
score | $score | score, level, board |
progression | $progression | milestone, value |
purchase | $purchase | value, currency, items, and the store and its transaction id when you pass them |
A purchase with its store (apple, google_play, steam) and the store's transaction id counts once, even when the store reports the same purchase to Mode too. Purchases show in Revenue like any other.
Everything else is capture with your own name and properties, plus identify, alias, group, reset, register, register_once, register_for_session, set_person_properties, unset_person_properties, feature flags, flush and shutdown.
Godot
Godot 4.2 and later, on desktop, mobile and the web export.
curl -fsSLO https://gotmode.com/sdk/godot/0.1.0/mode_metrics-godot-0.1.0.zip echo "a5cddbe337d10c3646c6b4c899d1c02ef38d8b9473e4c737fe1cec6b9d9de88b mode_metrics-godot-0.1.0.zip" | shasum -a 256 -c unzip mode_metrics-godot-0.1.0.zip -d path/to/your/project
That adds addons/mode_metrics to your project. Enable Mode Metrics in Project Settings, Plugins. Set the key and host under Project Settings, Mode Metrics, and it starts with the game as the autoload Mode.
| File | Version | SHA-256 |
|---|---|---|
mode_metrics-godot-0.1.0.zip | 0.1.0 | a5cddbe337d10c3646c6b4c899d1c02ef38d8b9473e4c737fe1cec6b9d9de88b |
Mode.level_start("lock-lane") Mode.level_fail("lock-lane", "death", 1200) Mode.purchase("gems_100", 0.99, "USD", {"source": "google_play", "transaction_id": order_id})
On the web export, when the page that hosts the game loads the Mode snippet, the game hands it every call, so the game and the page are one visitor with one session and one consent choice. Set web_bridge to required to send nothing from copies of the game hosted without the snippet.
Errors are captured on Godot 4.5 and later.
Unity
Unity 2021.3 and later, in the editor and every build target, WebGL included.
curl -fsSLO https://gotmode.com/sdk/unity/0.1.0/com.gotmode.metrics-0.1.0.tgz echo "82dc590ffdaf8a66ae126290b62ec9c720de80013ab5a403563ec3c804787c5b com.gotmode.metrics-0.1.0.tgz" | shasum -a 256 -c
In the Package Manager, choose the add button, then Install package from tarball, and pick the file. Keep the file in your project, for example in a Packages folder, since the project refers to it. Then open Project Settings, Mode Metrics and set the key and host. It starts before the first scene loads.
| File | Version | SHA-256 |
|---|---|---|
com.gotmode.metrics-0.1.0.tgz | 0.1.0 | 82dc590ffdaf8a66ae126290b62ec9c720de80013ab5a403563ec3c804787c5b |
com.gotmode.metrics.purchasing-0.1.0.tgz | 0.1.0 | c192a0056579b9918e51d8e17226321da142032692a8747bc7e55b9ab1a8a559 |
using Mode.Metrics; ModeMetrics.LevelStart("cave"); ModeMetrics.LevelFail("cave", "death", 1200); ModeMetrics.Purchase("gems_100", 0.99, "USD", 1, transactionId, "apple");
With Unity IAP, also install the purchasing package (com.gotmode.metrics.purchasing-0.1.0.tgz, the same way, after the core) and pass the store's product to ModePurchasing.Capture(product) after a purchase. Its price, currency, store and transaction id are filled in for you. A game without it carries no purchasing code. Scenes come from SceneManager, pauses from Time.timeScale, and errors from Unity's log and unhandled exceptions.
Unreal Engine
Unreal Engine 5 on Windows, macOS, Linux, iOS and Android, with a Blueprint node for every call.
curl -fsSLO https://gotmode.com/sdk/unreal/0.1.0/ModeMetrics-unreal-0.1.0.zip echo "eaf5eca075191a8abb4bff582f34060943bdaf138500dd0639aa71e1eb99bc14 ModeMetrics-unreal-0.1.0.zip" | shasum -a 256 -c unzip ModeMetrics-unreal-0.1.0.zip -d path/to/your/project/Plugins
That adds Plugins/ModeMetrics to your project. Enable Mode Metrics in Edit, Plugins, and set the key and host in Project Settings, Plugins, Mode Metrics. The nodes are on the Mode Metrics Subsystem of the game instance.
| File | Version | SHA-256 |
|---|---|---|
ModeMetrics-unreal-0.1.0.zip | 0.1.0 | eaf5eca075191a8abb4bff582f34060943bdaf138500dd0639aa71e1eb99bc14 |
auto* Mode = GetGameInstance()->GetSubsystem<UModeMetricsSubsystem>(); Mode->LevelStart(TEXT("1-1"), {}); Mode->LevelComplete(TEXT("1-1"), 4200.f, {});
Maps are captured with their exact load time, and a crash is named by the engine's own error and sent on the next launch.
Roblox
A server module, with a small client relay for what only a player's device knows.
curl -fsSLO https://gotmode.com/sdk/roblox/0.1.0/ModeMetrics-roblox-0.1.0.rbxmx echo "a8ae6adef0b695e6cb057563844382b0a82a18bdae27b659fc44b280981692f8 ModeMetrics-roblox-0.1.0.rbxmx" | shasum -a 256 -c
| File | Version | SHA-256 |
|---|---|---|
ModeMetrics-roblox-0.1.0.rbxmx | 0.1.0 | a8ae6adef0b695e6cb057563844382b0a82a18bdae27b659fc44b280981692f8 |
In Studio, right click ServerScriptService, choose Insert from File and pick the file. It adds a ModeMetrics folder. Move the Mode module out of it into ServerScriptService itself, ModeClient to StarterPlayerScripts and ModeLoad to ReplicatedFirst, then delete the empty folder. In Game Settings, Security, turn on Allow HTTP Requests. In the experience's Secrets on Creator Hub, add mode_key with a Mode Metrics secret key (msk_), so the key stays on the server.
local Mode = require(game.ServerScriptService.Mode) Mode.init({ host = "https://m.example.com" }) Mode.level_start(player, "obby-3") MarketplaceService.ProcessReceipt = Mode.wrapProcessReceipt(processReceipt)
Each player is a person by their user id, and each visit is a session from join to leave, with teleports noted. Game pass and developer product purchases are captured in Robux, and a receipt counts once. Script errors on the server and on players' devices are captured with player names removed. The relay reports the device type, screen, language, load time and frame rate, and the server checks and limits everything a client sends.
Other engines
A C library for any engine or tool with a C compiler, such as Defold or GameMaker native extensions, Cocos or your own engine.
curl -fsSLO https://gotmode.com/sdk/c/0.2.0/mode-metrics-c-0.2.0.zip echo "a8206287778d87d14fe34ae4303b5b19eb7db322909b56589b6c72a37f191f59 mode-metrics-c-0.2.0.zip" | shasum -a 256 -c unzip mode-metrics-c-0.2.0.zip
| File | Version | SHA-256 |
|---|---|---|
mode-metrics-c-0.2.0.zip | 0.2.0 | a8206287778d87d14fe34ae4303b5b19eb7db322909b56589b6c72a37f191f59 |
Add the unzipped folder to your build with add_subdirectory in CMake, or build it on its own with CMake. Call mode_init once, mode_frame and mode_tick every frame, and report what your engine knows (mode_screen, mode_game_paused, mode_app_background, mode_exception). Properties are JSON text. With libcurl it sends on a thread of its own, or you give it your engine's HTTP client.
mode_config cfg; mode_config_defaults(&cfg); cfg.key = "YOUR_INGEST_KEY"; cfg.host = "https://m.example.com"; cfg.storage_dir = save_dir; mode_client *mode = mode_init(&cfg); mode_level_start(mode, "1", NULL);
Privacy and consent
Nothing personal is sent unless you send it.
Error messages lose email addresses, secret link parameters, home folder names and long numbers before they leave the device. Start with consent set to pending to keep everything in memory until the player answers, then call set_consent. opt_out stops capture and is remembered, and default_opt_out starts every new install opted out. before_send sees each event last and can change or drop it.