Unity SDK Integration
Unity SDK Integration
Section titled “Unity SDK Integration”Integrate BoostOps into your Unity game project in just a few minutes. Our SDK is designed to be lightweight, easy to use, and compatible with your existing analytics setup.
Prerequisites
Section titled “Prerequisites”Before you begin, ensure you have:
- Unity 2019.4 LTS or later (recommended: Unity 2021.3 LTS+)
- iOS 10.0+ or Android API level 19+ target
- BoostOps account with Game ID and API Key
- Firebase project (optional but recommended for enhanced tracking)
Installation
Section titled “Installation”Method 1: Package Manager (Recommended)
Section titled “Method 1: Package Manager (Recommended)”-
Open Unity Package Manager
- Go to
Window
→Package Manager
- Click the
+
button in top-left corner - Select
Add package from git URL...
- Go to
-
Add BoostOps SDK
https://github.com/boostops/unity-sdk.git -
Import the Package
- Click
Add
and wait for the package to download - The SDK will appear in your Package Manager as “BoostOps Unity SDK”
- Click
Method 2: Manual Installation
Section titled “Method 2: Manual Installation”-
Download the Package
- Go to GitHub Releases
- Download the latest
.unitypackage
file
-
Import into Unity
- In Unity, go to
Assets
→Import Package
→Custom Package
- Select the downloaded
.unitypackage
file - Click
Import
to add all files
- In Unity, go to
Initial Setup
Section titled “Initial Setup”1. Get Your API Keys
Section titled “1. Get Your API Keys”-
Log into BoostOps Dashboard
- Visit app.boostops.com
- Navigate to your game project
-
Generate SDK Keys
- Go to
Settings
→SDK Integration
- Click
Generate New Keys
if not already created - Copy both
Game ID
andAPI Key
- Go to
2. Initialize BoostOps
Section titled “2. Initialize BoostOps”Create a initialization script in your main game manager:
using UnityEngine;using BoostOps;
public class GameManager : MonoBehaviour{ [Header("BoostOps Configuration")] [SerializeField] private string gameId = "YOUR_GAME_ID"; [SerializeField] private string apiKey = "YOUR_API_KEY"; [SerializeField] private bool enableDebugLogging = true;
void Start() { // Initialize BoostOps BoostOpsSDK.Initialize(gameId, apiKey, enableDebugLogging);
// Optional: Set user properties BoostOpsSDK.SetUserProperty("first_launch", System.DateTime.Now.ToString());
Debug.Log("BoostOps SDK initialized successfully"); }}
3. Basic Event Tracking
Section titled “3. Basic Event Tracking”Add essential game events to start tracking:
public class GameEvents : MonoBehaviour{ void Start() { // Track game start BoostOpsSDK.TrackEvent("game_start"); }
public void OnLevelComplete(int level) { // Track level completion with parameters var parameters = new Dictionary<string, object> { {"level", level}, {"time_taken", Time.time}, {"score", GetCurrentScore()} };
BoostOpsSDK.TrackEvent("level_complete", parameters); }
public void OnInAppPurchase(string productId, float amount, string currency) { // Track revenue events (critical for profitability tracking) var parameters = new Dictionary<string, object> { {"product_id", productId}, {"amount", amount}, {"currency", currency} };
BoostOpsSDK.TrackRevenue("iap_purchase", amount, currency, parameters); }
public void OnAdWatched(string placement, float rewardAmount = 0) { // Track ad events for monetization analysis var parameters = new Dictionary<string, object> { {"placement", placement}, {"reward_amount", rewardAmount} };
BoostOpsSDK.TrackEvent("ad_watched", parameters); }}
Advanced Configuration
Section titled “Advanced Configuration”User Identification
Section titled “User Identification”For better analytics and cross-platform tracking:
public void SetupUserIdentification(){ // Set unique user ID (use your existing user system) BoostOpsSDK.SetUserId("user_12345");
// Set user properties for segmentation BoostOpsSDK.SetUserProperty("user_type", "premium"); BoostOpsSDK.SetUserProperty("registration_date", "2024-01-15"); BoostOpsSDK.SetUserProperty("total_purchases", 3);}
Custom Events for Executive Dashboard
Section titled “Custom Events for Executive Dashboard”Track metrics that matter for executive reporting:
public class ExecutiveMetrics : MonoBehaviour{ public void TrackSessionMetrics() { // Track session quality metrics BoostOpsSDK.TrackEvent("session_start", new Dictionary<string, object> { {"session_length_target", 300}, // 5 minutes target {"app_version", Application.version} }); }
public void TrackRetentionMilestones(int daysSinceInstall) { // Track retention milestones for executive dashboard if (daysSinceInstall == 1) BoostOpsSDK.TrackEvent("day_1_retention"); else if (daysSinceInstall == 7) BoostOpsSDK.TrackEvent("day_7_retention"); else if (daysSinceInstall == 30) BoostOpsSDK.TrackEvent("day_30_retention"); }
public void TrackRevenueMetrics(float totalSpent, string category) { // Critical for ad spend profitability calculations BoostOpsSDK.TrackRevenue("user_spending", totalSpent, "USD", new Dictionary<string, object> { {"category", category}, {"user_lifetime_value", CalculateUserLTV()} }); }}
Performance Optimization
Section titled “Performance Optimization”Configure the SDK for optimal performance:
public void ConfigureSDKPerformance(){ // Batch events for better performance BoostOpsSDK.SetEventBatchSize(10);
// Set flush interval (seconds) BoostOpsSDK.SetFlushInterval(30);
// Enable/disable based on build type#if DEVELOPMENT_BUILD BoostOpsSDK.EnableDebugLogging(true);#else BoostOpsSDK.EnableDebugLogging(false);#endif}
Platform-Specific Setup
Section titled “Platform-Specific Setup”iOS Configuration
Section titled “iOS Configuration”Add these entries to your Info.plist
:
<dict> <!-- Allow network access for analytics --> <key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>boostops.com</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> </dict></dict>
Android Configuration
Section titled “Android Configuration”Add permissions to your AndroidManifest.xml
:
<manifest> <!-- Required for analytics --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Optional: For better user tracking --> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /></manifest>
Testing Your Integration
Section titled “Testing Your Integration”Verify SDK Initialization
Section titled “Verify SDK Initialization”void Start(){ BoostOpsSDK.Initialize(gameId, apiKey, true);
// Check if initialization was successful if (BoostOpsSDK.IsInitialized()) { Debug.Log("✅ BoostOps SDK initialized successfully");
// Send test event BoostOpsSDK.TrackEvent("sdk_test", new Dictionary<string, object> { {"test_timestamp", System.DateTime.UtcNow.ToString()}, {"unity_version", Application.unityVersion} }); } else { Debug.LogError("❌ BoostOps SDK initialization failed"); }}
Debug Mode
Section titled “Debug Mode”Enable debug logging to see SDK activity:
// Enable detailed logging in developmentBoostOpsSDK.EnableDebugLogging(true);
// This will show:// - Event tracking confirmations// - Network request status// - Error messages and warnings
Test in BoostOps Dashboard
Section titled “Test in BoostOps Dashboard”- Run your game with the SDK integrated
- Perform test actions (start game, complete level, make purchase)
- Check BoostOps Dashboard → Real-time Events
- Verify events appear within 5-10 minutes
Common Integration Patterns
Section titled “Common Integration Patterns”Singleton Pattern
Section titled “Singleton Pattern”public class AnalyticsManager : MonoBehaviour{ public static AnalyticsManager Instance { get; private set; }
void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); InitializeAnalytics(); } else { Destroy(gameObject); } }
private void InitializeAnalytics() { BoostOpsSDK.Initialize(gameId, apiKey, enableDebugLogging); }
public void TrackGameEvent(string eventName, Dictionary<string, object> parameters = null) { BoostOpsSDK.TrackEvent(eventName, parameters); }}
Event Manager Pattern
Section titled “Event Manager Pattern”public static class GameAnalytics{ public static void LevelStarted(int level, string difficulty) { BoostOpsSDK.TrackEvent("level_start", new Dictionary<string, object> { {"level", level}, {"difficulty", difficulty}, {"timestamp", Time.time} }); }
public static void PurchaseCompleted(string productId, float price) { BoostOpsSDK.TrackRevenue("purchase", price, "USD", new Dictionary<string, object> { {"product_id", productId} }); }}
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”SDK not initializing:
- Verify your Game ID and API Key are correct
- Check internet connectivity
- Ensure you’re calling Initialize before other SDK methods
Events not appearing in dashboard:
- Wait 5-10 minutes for data processing
- Check debug logs for error messages
- Verify your app is in foreground when sending events
Build errors:
- Make sure Unity version is 2019.4+
- Check that all required dependencies are installed
- Try reimporting the BoostOps package
Getting Help
Section titled “Getting Help”- Quick Start Guide - Step-by-step setup
- Contact Support - Technical assistance
- FAQ - Common questions
Ready to start tracking? Your executive dashboard will show data within 24 hours of integration.