Analytics can also be a basic tool in understanding player behavior, adjusting the design of your game, and making more data-driven decisions. In this post we’ll show how to use third-party analytics in your Unity project, which will help you find important insights into your game’s performance and engagement of players.
Why do we need Third-Party Analytics?
Unity comes with its analytics solution, but third-party tools usually offer more advanced features, cross-platform support, and specialized game analytics. Some popular alternatives include:
- Google Analytics for Firebase
- GameAnalytics
- deltaDNA
- Amplitude
Setting Up Analytics: Step by Step
For this example, we’ll use Google Analytics for Firebase, though the process is similar for most analytics platforms:
Create a Firebase Project
Open the Firebase Console and set up a new game project.
Add Firebase to your Unity Project
Download the Firebase Unity SDK and import it into your project. Follow the setup in the Firebase documentation for your project settings.
Initialize Firebase Analytics
Append the following code to initialize Firebase Analytics in your game:
using Firebase; using Firebase.Analytics; public class AnalyticsManager : MonoBehaviour { void Start() { FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => { var dependencyStatus = task.Result; if (dependencyStatus == DependencyStatus.Available) { // Create and hold a reference to your FirebaseApp, // where app is a Firebase.FirebaseApp property of your application class. FirebaseApp app = FirebaseApp.DefaultInstance; // Set a flag here to indicate whether Firebase is ready to use by your app. FirebaseAnalytics.SetAnalyticsCollectionEnabled(true); } else { Debug.LogError($"Could not resolve all Firebase dependencies: {dependencyStatus}"); } }); } }
Track Events
Use Firebase Analytics to track specific events in your game. For example:
public void LevelComplete(int levelNumber) { Firebase.Analytics.Parameter[] parameters = { new Firebase.Analytics.Parameter("level_number", levelNumber) }; Firebase.Analytics.FirebaseAnalytics.LogEvent("level_complete", parameters); }
Set User Properties
You can set user properties to segment your audience:
Firebase.Analytics.FirebaseAnalytics.SetUserProperty("favorite_character", "OUIJA");
Best Practices for Game Analytics
Monitor Actionable Events: Monitor only meaningful events, like percentage completion of levels, in-app purchases, and player’s progression.
Respect Users’ Privacy: Always respect privacy laws and platform policies. Provide fair options for opt-outs with respect to users.
Utilize Custom Dimensions: Optimize and slice your data using custom dimensions to get more details on player behavior.
Ensure Performance Impact: Make sure the analytics implementation does not harm game performance.
Data Review: Develop dashboards and review analytics systematically to detect trends and improvement areas.
Conclusion
After deploying third-party analytics into your Unity game, it delivers amazing insights which can be used to create a better experience for the player and keeping them intact for much longer durations, and so on, maximally monetize these users, and so on. Thus, by adapting to best practices and choosing the right analytics, you will be in a much better position to make data-driven decisions leading to the success of your game.