Skip to content

Unity SDK

The Vortex Analytics Unity SDK supports immediate and batched event tracking, automatic session management, and graceful flush on app quit.

Minimum Unity version: 2021.3
Package name: io.vortexanalytics.unity-sdk
GitHub: Vortex-Analytics-IO/Unity-SDK


  1. Open Window → Package Manager

  2. Click +Add package from git URL…

  3. Paste the URL below and click Add

    https://github.com/Vortex-Analytics-IO/Unity-SDK.git
  1. Clone or download the repository
  2. Open Window → Package Manager
  3. Click +Add package from disk…
  4. Select the package.json at the root of the repo

  1. Open Tools → Vortex Analytics → Add Analytics Manager to Scene
    (or add the AnalyticsManager component to any persistent GameObject manually)
  2. In the Inspector, fill in Tenant ID and Platform
  3. Press Play — the SDK validates your tenant and starts tracking

Attach the AnalyticsManager component to a GameObject and configure:

FieldDescription
Initialize On AwakeWhen enabled, Initialize() is called automatically on startup
Enable AnalyticsMaster switch — disable to prevent any data from being sent
Tenant IDYour unique project identifier from the Vortex dashboard
UrlServer endpoint (default: https://in.vortexanalytics.io)
PlatformPlatform string, e.g. STEAM, IOS, ANDROID

If you need to initialize at runtime (e.g. after a consent flow):

using Vortex.Analytics;
AnalyticsManager.Instance.Init(
tenantId: "mygame",
url: "https://in.vortexanalytics.io",
platform: "STEAM"
);
  1. Generates or loads a persistent device identifier
  2. Creates a new session ID
  3. Performs a server health check
  4. Enables or disables analytics based on server availability

If the server is unreachable, events are safely queued until connectivity is restored.


You can toggle analytics at runtime — useful for GDPR consent or user opt-out flows.

// Stop all tracking and background routines
AnalyticsManager.Instance.SetAnalyticsEnabled(false);
// Restart health checks and flushing routines
AnalyticsManager.Instance.SetAnalyticsEnabled(true);

When disabled:

  • All TrackEvent and BatchedTrackEvent calls are ignored immediately
  • Background flush routines are stopped to save resources
  • Server health checks are paused

All scripts that use the SDK must add:

using Vortex.Analytics;
AnalyticsManager.Instance.TrackEvent("app_started");
AnalyticsManager.Instance.TrackEvent("menu_opened", "settings");
AnalyticsManager.Instance.TrackEvent("level_completed", new Dictionary<string, object>
{
{ "level", 5 },
{ "difficulty", "Hard" },
{ "time", 123.4f }
});

Use manual batching when you want explicit control over when events are sent (e.g. at the end of a match).

// Queue events
AnalyticsManager.Instance.BatchedTrackEvent("EnemyKilled");
AnalyticsManager.Instance.BatchedTrackEvent(
"ItemCrafted",
new Dictionary<string, object>
{
{ "item", "MagicSword" },
{ "rarity", "Epic" }
}
);
// Send all queued events in a single HTTP request
AnalyticsManager.Instance.FlushManualBatch();

When Auto Batching is enabled in the Inspector:

  • Events are queued automatically
  • The system flushes the queue every Auto Flush Interval seconds
  • If the server is unreachable, events remain queued until it responds

Attach a persistent JSON object to every event the manager sends.

// Set custom data — included in all subsequent events
AnalyticsManager.Instance.SetCustomData(new Dictionary<string, object>
{
{ "region", "EU" },
{ "premium", true },
{ "user_level", 10 }
});
// Remove custom data
AnalyticsManager.Instance.ClearCustomData();
  • Empty custom data is not sent in requests (keeps payloads minimal)
  • Changing custom data only affects new events; already-sent events are not modified

Analytics are flushed automatically when:

  • The application loses focus (mobile background)
  • The application is paused (mobile)
  • The application is quitting

No manual Shutdown() call is required in Unity.


A Basic Usage sample is bundled with the package.
Import it via Window → Package Manager → Vortex Analytics → Samples → Basic Usage → Import.