Before you start
- Your project’s publishable key, from Game Analytics > Connect your game or Settings > General in Audience. It starts with
pk_imapik-. - The player’s consent, recorded before you send their events. The HTTP API doesn’t check consent for you. See Consent.
Send events
SendPOST requests to https://api.immutable.com/v1/audience/messages, with your key in the x-immutable-publishable-key header. Each request carries up to 100 messages.
messageIdis a UUID you generate for each message. Audience uses it to drop duplicates, so reuse it when you retry.anonymousIdidentifies the device. Use the same one across a player’s requests to join up their activity.userIdidentifies the player. Send it only atfullconsent.surfacesays where the event came from:unityorunrealfor events from a game,webfor website traffic. Game Analytics counts onlyunityandunreal, so an event sent asweb, or with nosurface, is stored but doesn’t show there.context.librarynames your system, such asmy-game-server. Don’t use@imtbl/audienceorcom.immutable.audience: those belong to the SDKs.
Read the response
rejections with its messageId and the field that failed. When every message in a request fails, the response is 400 with the same shape.
Consent
Atnone, send nothing. At anonymous, leave out userId and anything that identifies the player. At full, send everything.
To record a player’s choice with Audience:
Test your setup
Add"test": true to a message while you build. Test events show in the event log but stay out of your boards.
Check it’s working
A200 with "accepted": 1 means Audience has the event. In Audience, Game Analytics > Connect your game shows First event received within a few minutes. See Check your events arrive.
Related
- Consent
- Check your events arrive
- HTTP API reference: every field, event type and the data deletion endpoint