Skip to main content
Install the Unity SDK to send events and player identity from your Unity game to Audience. It also tracks launches, sessions and scene loads by itself.

Before you start

  • Your project’s publishable key, from Game Analytics > Connect your game or Settings > General in Audience. It starts with pk_imapik-.
  • Unity 2021.3 or later, with Mono or IL2CPP.
  • A supported platform: Android, iOS, Windows 10 or later (64-bit), macOS or Linux (64-bit).

Install

  1. In Unity, open Window > Package Manager.
  2. Select + > Add package from git URL… and paste:

Set up with the install wizard

The install wizard opens the first time Unity loads the package without an ImmutableAudience.Init call in your scripts. To open it any time, go to Tools > Immutable > Audience > Install Wizard. It checks your publishable key, sends one test message, and gives you the Init code for your consent level. Copy the code, or select Create script for me to save it as Assets/AudienceSetup.cs.

Start the SDK

Consent defaults to ConsentLevel.None, which sends nothing. This example starts at Anonymous, so events flow straight away without identifying the player.

Track events

The predefined events are Progression, Resource, Purchase, AchievementUnlocked and MilestoneReached. For a custom event, add using System.Collections.Generic;.

Identify players

Call Identify when a player signs in. It needs Full consent: raise it only after the player agrees.

What the SDK captures by itself

The SDK sends game_launch, first_launch, app_updated, session_start, session_heartbeat, session_end, scene_loaded and scene_unloaded. Turn each on or off in AudienceConfig.Autocapture. The SDK sends queued events and shuts down when the game quits.

Test your setup

While you build, set TestMode = true in AudienceConfig. Test events show in the event log but stay out of your boards. Set Debug = true to log every event to the Unity Console. Remove both before you release: the install wizard warns about a leftover TestMode.

Check it’s working

Press Play. ImmutableAudience.Initialized returns true, and in Audience Game Analytics > Connect your game shows First event received within a few minutes. See Check your events arrive.