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
Installation
Section titled “Installation”Option 1 — Git URL (recommended)
Section titled “Option 1 — Git URL (recommended)”-
Open Window → Package Manager
-
Click + → Add package from git URL…
-
Paste the URL below and click Add
https://github.com/Vortex-Analytics-IO/Unity-SDK.git
Option 2 — Local disk
Section titled “Option 2 — Local disk”- Clone or download the repository
- Open Window → Package Manager
- Click + → Add package from disk…
- Select the
package.jsonat the root of the repo
Quick start
Section titled “Quick start”- Open Tools → Vortex Analytics → Add Analytics Manager to Scene
(or add theAnalyticsManagercomponent to any persistent GameObject manually) - In the Inspector, fill in Tenant ID and Platform
- Press Play — the SDK validates your tenant and starts tracking
Initialization
Section titled “Initialization”Automatic (recommended)
Section titled “Automatic (recommended)”Attach the AnalyticsManager component to a GameObject and configure:
| Field | Description |
|---|---|
| Initialize On Awake | When enabled, Initialize() is called automatically on startup |
| Enable Analytics | Master switch — disable to prevent any data from being sent |
| Tenant ID | Your unique project identifier from the Vortex dashboard |
| Url | Server endpoint (default: https://in.vortexanalytics.io) |
| Platform | Platform string, e.g. STEAM, IOS, ANDROID |
Manual
Section titled “Manual”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");What happens on initialization
Section titled “What happens on initialization”- Generates or loads a persistent device identifier
- Creates a new session ID
- Performs a server health check
- Enables or disables analytics based on server availability
If the server is unreachable, events are safely queued until connectivity is restored.
Runtime control
Section titled “Runtime control”You can toggle analytics at runtime — useful for GDPR consent or user opt-out flows.
// Stop all tracking and background routinesAnalyticsManager.Instance.SetAnalyticsEnabled(false);
// Restart health checks and flushing routinesAnalyticsManager.Instance.SetAnalyticsEnabled(true);When disabled:
- All
TrackEventandBatchedTrackEventcalls are ignored immediately - Background flush routines are stopped to save resources
- Server health checks are paused
Tracking events
Section titled “Tracking events”All scripts that use the SDK must add:
using Vortex.Analytics;Simple event
Section titled “Simple event”AnalyticsManager.Instance.TrackEvent("app_started");Event with string payload
Section titled “Event with string payload”AnalyticsManager.Instance.TrackEvent("menu_opened", "settings");Event with structured data
Section titled “Event with structured data”AnalyticsManager.Instance.TrackEvent("level_completed", new Dictionary<string, object>{ { "level", 5 }, { "difficulty", "Hard" }, { "time", 123.4f }});Batching
Section titled “Batching”Manual batching
Section titled “Manual batching”Use manual batching when you want explicit control over when events are sent (e.g. at the end of a match).
// Queue eventsAnalyticsManager.Instance.BatchedTrackEvent("EnemyKilled");
AnalyticsManager.Instance.BatchedTrackEvent( "ItemCrafted", new Dictionary<string, object> { { "item", "MagicSword" }, { "rarity", "Epic" } });
// Send all queued events in a single HTTP requestAnalyticsManager.Instance.FlushManualBatch();Automatic batching
Section titled “Automatic batching”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
Custom data
Section titled “Custom data”Attach a persistent JSON object to every event the manager sends.
// Set custom data — included in all subsequent eventsAnalyticsManager.Instance.SetCustomData(new Dictionary<string, object>{ { "region", "EU" }, { "premium", true }, { "user_level", 10 }});
// Remove custom dataAnalyticsManager.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
Lifecycle
Section titled “Lifecycle”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.
Samples
Section titled “Samples”A Basic Usage sample is bundled with the package.
Import it via Window → Package Manager → Vortex Analytics → Samples → Basic Usage → Import.