Who sends what
A server build is not a player
The game SDKs know when they run in a dedicated server build:
In a server build, the SDK does not send
game_open, session_start, session_end, or game_crash. So the server does not count as an install, a player session, or a crash. It logs one line that tells you why.
Your own track() and identify() calls still work. They use the server’s own anonymous ID, so they do not join a player. Use them only for events about the server itself, for example server_start. Set build (for example "server") so you can filter them.
To send the automatic events from a server build anyway, turn on the option:
For example, a listen server (a host who also plays) is a player. In Godot, a host started with
--headless for a test is a server build. Turn the option on for these runs.
Send results from the server
Results that the server decides belong to the player, not to the server. Send them from the server with the player’s IDs. This is the same pattern as a web checkout: the client sends its IDs, and the backend sends the event.1
Send the IDs to the server
The client sends its
anonymous_id and session_id to the server, for example when it joins the match.2
Send the event from the server
The server sends the event with the Node.js SDK in server mode, or with the HTTP API. It uses the secret key, and sets
anonymous_id and session_id of that player. When you know the player’s account, add user_id.Node.js
HTTP
curl example), or from a backend in Node.js.
Purchases
The client can send apurchase event at once. When your server checks the receipt, send the checked purchase from the server with the player’s IDs. Add validated: true so you can tell the two apart. See Server events.
Checklist
- Each client uses the publishable key and tracks its own player.
- A server build sends no
game_openand no sessions, unless you turn on the option. - The server sends match results and checked purchases with the secret key, the player’s
anonymous_id, and the player’ssession_id. - The secret key is never in a client build.