Installation
Install the game-events.io plugin directly into your Unity project using the Unity Package Manager (UPM).
- Open Unity and go to Window > Package Manager.
- Click the + button in the top left corner.
- Select Add package from git URL...
- Paste the URL above and click Add.
Initialization
Initialize game-events.io at the start of your game, typically in your first scene's Awake method.
using UnityEngine;
using GameEventsIO;
public class GameManager : MonoBehaviour
{
void Awake()
{
// Initialize with your Project API Key
// Pass 'true' as the second argument to enable debug logging
GameEventsIOSDK.Initialize("YOUR_API_KEY_HERE", true);
}
}Usage
Track custom events with properties to understand player behavior.
GameEventsIOSDK.LogEvent("level_started");var props = new Dictionary<string, object>
{
{ "level_id", 5 },
{ "difficulty", "hard" },
{ "gold_balance", 1500 }
};
GameEventsIOSDK.LogEvent("level_completed", props);// It's that simple. No complex setup required.
GameEventsIOSDK.SetUserProperty("subscription_type", "premium");
// Set multiple user properties
var userProps = new Dictionary<string, object>
{
{ "level", 10 },
{ "guild", "Warriors" }
};
GameEventsIOSDK.SetUserProperties(userProps);// Simple A/B Test implementation
if (!PlayerPrefs.HasKey("ab_ad_frequency"))
{
var testOptions = new [] { "rare", "often" };
var variant = testOptions[Random.Range(0, testOptions.Length)];
PlayerPrefs.SetString("ab_ad_frequency", variant);
}
// Track the assigned variant as a user property
var assignedVariant = PlayerPrefs.GetString("ab_ad_frequency");
GameEventsIOSDK.SetUserProperty("ab_ad_frequency", assignedVariant);MMP & Attribution
To enable attribution on iOS (version 14.5+), you must request user permission for tracking.
Important: Request permission BEFORE initializing the analytics SDK. This ensures that the Advertising ID (IDFA) is captured and sent with your first events (e.g., session_start).
How to do it:
Add the code below to the Start or Awake method of your main script (e.g., GameManager) attached to a GameObject in your game's first scene.
On Android, no extra action is required — the plugin automatically collects the Advertising ID.
// iOS 14+ App Tracking Transparency
void Awake()
{
#if UNITY_IOS
// On iOS, request permission first, then initialize
GameEventsIOSDK.RequestTrackingAuthorization((status) =>
{
Debug.Log($"ATT Status: {status}");
GameEventsIOSDK.Initialize("YOUR_API_KEY_HERE", true);
});
#else
// On other platforms, initialize immediately
GameEventsIOSDK.Initialize("YOUR_API_KEY_HERE");
#endif
}