> ## Documentation Index
> Fetch the complete documentation index at: https://docs.manalens.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# For console games

> For console games: send PlayStation, Xbox and Switch builds with the right platform and store, keep the anonymous ID in save data, count installs once.

This guide is for studios that ship a Unity, Unreal or Godot game on PlayStation, Xbox or Nintendo Switch. It covers three things to get right in each console build:

* The **platform and store values**, so reports split console players from PC players.
* A **stable anonymous ID** in console save data, so one player is one player.
* **Each install counted once**, so installs are not counted again after a restart or an update.

A console build sends the same events as a PC build. The difference is where the SDK can keep its anonymous ID, and how the console saves data. Check the points below before you ship a console build.

> [!NOTE]
>
> The Unreal plugin builds for console targets from plugin 0.14.0: its `Manalens` module excludes only tvOS and visionOS. Send one test event from each console build before you ship.

## Platform and store values

Each event has `context.app.platform` and `context.app.storefront`. Reports split by them in the **Platform** and **Storefront** breakdowns and filters.

| Console | `platform` | `storefront` |
| - | - | - |
| PlayStation 5 | `ps5` | `psn` |
| Xbox Series X and S | `xbox_series` | `xbox` |
| Xbox One | `xbox_one` | `xbox` |
| Nintendo Switch | `switch` | `nintendo` |
| Nintendo Switch 2 | `switch2` | `nintendo` |

How each SDK sets `platform`:

| Engine | Detection | Override |
| - | - | - |
| Unity | `Application.platform`: PS5, GameCoreXboxSeries, GameCoreXboxOne, XboxOne, and Switch | `Platform` in `ManalensOptions`, for example `"switch2"` |
| Unreal | The console platform macros (plugin 0.14.0 and later) | The **Platform** setting, in that platform's own `Game.ini` |
| Godot | None. Godot runs on consoles through third-party ports. | The `platform` option in `init()` |

Set `storefront` in each console build, as you do for Steam or itch.io builds. Engine and port versions differ, so send one test event from each console build and check its platform on the **Activity** page.

## Keep a stable anonymous ID

The SDK makes a random anonymous ID on the first launch and keeps it in a file:

| Engine | File |
| - | - |
| Godot | `user://manalens.cfg` |
| Unity | `Application.persistentDataPath` |
| Unreal | `Saved/Manalens` |

On a PC, this file stays between launches. On a console, a folder can be temporary, or it can need the save data system to keep it. If the file does not stay, each launch makes a new anonymous ID. Then one player counts as many players, and each launch counts as a new install.

Make sure the file is in the console's save data:

* Check in your platform's documentation where the engine path goes on that console. Also check whether it is kept after a restart and after a game update.
* If it is not kept, point the engine path at save data. Or keep the SDK files in your save data with the rest of your game's saves.
* Test it. Launch the game, quit, and launch again. The second `game_open` must have `is_first_open: false` and the same `anonymous_id`.

Console save data is per user account. So an ID in save data counts a player account on that console, not the console. Two family members on one console are two players. That is usually what you want.

## Detect the first open

If the SDK finds no saved anonymous ID, it sends `game_open` with `is_first_open: true`. Manalens counts that event as an install. So first-open detection needs a kept ID (see above).

Things that make a false first open on a console:

* The SDK file is not in save data, so it is lost at each restart.
* The player deletes the save data. This is a new install for Manalens, as a reinstall on a PC.
* Save data that is written but not committed (see [Switch](#commit-save-data-on-switch)).

## Use network time for first\_open\_at

`game_open` also has `first_open_at`, the time of the first launch. The SDK takes it from the device clock and keeps it. A console clock can be wrong. For example, the player sets it by hand, or the console was never online.

Manalens does not use the device clock for the event time. Each request has `sent_at`, and the ingestion API moves each event to the server's time. So the install time in reports is right, even with a wrong clock. Only the `first_open_at` property keeps the device time.

If you use `first_open_at` in your own reports or in your game, get the time from the network instead: from your game server, or from the platform's network time service. Do not trust the console clock for time-limited rewards or install dates.

## Xbox connected storage conflicts

On Xbox, save data in connected storage syncs to the cloud. A player who plays on two consoles, one of them offline, can get a sync conflict. The game must pick one version.

If the SDK files are in connected storage, a conflict can bring back an older anonymous ID or a different one. Choose a rule and apply it every time, for example keep the version with the earlier `first_open_at`. Keep the SDK files and the game save that they belong to together, so that one choice covers both.

Connected storage also moves the ID with the player. A player who signs in on a second Xbox keeps the same anonymous ID, so that console does not count as a new install.

## Commit save data on Switch

On Nintendo Switch, a write to save data is not kept until the game commits it. If the game stops before the commit, the write is lost.

The SDK writes its ID file on the first launch and its queue while the game runs, but it does not commit. Commit the save data after `init()` on the first launch. Commit it again each time your game saves. If you do not commit after the first launch, the next launch can make a new ID and count a second install.

Commit as the platform rules allow. Commit at the times your game already saves, not after each event.

## Send from the game or through your server

We recommend that the console build sends its events with the SDK. The SDK sets the platform, the store, the device details, and the first open for you.

Some games send their events to their own game server first. Your server can then send them to Manalens with the [server events API](https://docs.manalens.dev/sdks/server.md) and the secret key. Do these steps for each event that your server sends:

* Set `context.app` with `platform` and `storefront`, for example `ps5` and `psn`. Reports then split the event by console.
* Set `anonymous_id`, `user_id`, or both, so that the event joins the correct player. For `user_id`, use your own player ID.
* To get the country, send the player's IP address in `context.ip`.

An event that your server sends does not get all that an event from the SDK gets:

* Manalens uses `context.ip` only to find the country, in memory. It does not store the IP address.
* Install network matching does not run on server events. A first open that comes through your server is not matched to a website visit.
* Manalens keeps only some `context` fields of a server event: `app`, `page`, `locale`, the country, the device, OS, and browser, and the library name and version. It does not keep `context.screen`, `context.system`, or `context.utc_offset`. So reports have no device details for these events.

See [server events](https://docs.manalens.dev/sdks/server.md#context) for each `context` field.

## Attribution on console

A console store gives the game no click ID and no store referrer. So Manalens cannot read the campaign from the install, as it does with the [Google Play install referrer](https://docs.manalens.dev/attribution/installs.md#android-the-play-install-referrer). Use these ways to connect a console player to a campaign. The first ones are the most certain.

* **The same user ID on your website and in the game.** If the player signs in on your website and in the game with one account, identify the player with the same user ID in both. See [identify users](https://docs.manalens.dev/guides/identify-users.md). Use your own player ID (see [what certification tests](#what-certification-tests)).
* **The cross-domain link.** `GetCrossDomainUrl()` (Unity and Unreal) and `get_cross_domain_url()` (Godot) add the anonymous ID to a website URL. Use it only where the platform lets a game open a web page. See [one player on the website and in the game](https://docs.manalens.dev/guides/identify-users.md#one-player-on-the-website-and-in-the-game).
* **UTM links to your website.** Add `utm_` fields to the links that go to your website. The website visit then has the campaign. A user ID, a cross-domain link, or a network match connects the visit to the install. Manalens reads store campaign data only from [Steam UTM Analytics](https://docs.manalens.dev/integrations/steam.md#automatic-utm-import) and from the Google Play install referrer. It reads no campaign data from PlayStation, Xbox, or Nintendo stores.
* **The network match.** Manalens matches the first `game_open` of a console build to website visitors on the same network, as on a PC. See [install attribution](https://docs.manalens.dev/attribution/installs.md#how-the-match-works). The match compares the operating system of the website visitor with the operating system of the game. The operating system of a console is usually not the one of the website visitor's device, so a console match usually has `low` confidence. To leave out these matches, set **Match confidence** to **Medium and high** on the Installs report.

## Store sales data

Manalens imports store data from Steam and from itch.io. See [Steam](https://docs.manalens.dev/integrations/steam.md) and [itch.io](https://docs.manalens.dev/integrations/itch.md). Manalens does not import sales from PlayStation, Xbox, or Nintendo.

To see console revenue, track the purchases yourself:

* **In the game:** send a `purchase` event with `revenue` and `currency`. See [revenue from custom events](https://docs.manalens.dev/features/revenue.md#revenue-from-custom-events).
* **From your server:** after your server checks the purchase with the platform, send a server event with the same `purchase` name. See [server events](https://docs.manalens.dev/sdks/server.md).

## What certification tests

Each platform holder has its own certification requirements, and they change. Read the current ones in the platform's developer portal. For analytics, the tests usually cover these areas:

* **No network.** The game must work offline and must not wait for the network. The SDKs send in the background. With no network, they keep events on disk, so the game does not wait.
* **Save data.** The game must handle full storage, damaged save data, and the save data rules of the platform. Include the SDK files in your save data tests.
* **User accounts.** The game must handle a user who signs out, or a change to another user. When the active user changes, call `reset()`. Then events of the new user do not join the old one.
* **Suspend and resume.** The game must resume without errors after the console suspends it. A send that stops during suspend is sent again later.
* **Privacy.** The game must follow the platform's rules for the data it collects and for consent. Tell players about analytics in your privacy policy. Use `consent_required` (Godot), `ConsentRequired` (Unity), or **Consent Required** (Unreal) where consent is necessary.

Do not send a raw platform account ID (for example a PSN account ID or an Xbox user ID) as the user ID. Check the platform's rules before you send any platform ID. Your own player ID, or no user ID, is safer.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.