Key Takeaways
- A solid Unity Firebase Analytics setup has two parts: the technical integration (SDK, config files, initialization) and a tracking plan that decides which events you log and why.
- Firebase’s Unity documentation lists Unity 2021 LTS or later as the supported baseline, and the Android package name or iOS bundle ID in Firebase must match your Unity project.
- Log a small set of meaningful events first, such as tutorial, level, reward and purchase events. Analytics supports up to 500 different event types and 25 user properties.
- Test with logcat and DebugView before you trust the dashboard, because normal events are batched and uploaded later.
- Declare analytics in your privacy policy and store forms, and handle consent where required.
Table of Contents
A good Unity Firebase Analytics setup takes less than an hour, but a good tracking plan takes some thought. Installing the SDK is easy. The harder questions are which player actions to measure, how to name events and how to confirm the data is correct before you make decisions from it.
This guide walks you through the full process: creating the Firebase project, adding config files, importing the SDK, writing initialization and logging code, testing with DebugView and handling privacy. We link the official Firebase pages, and because SDK versions and requirements change, we point out where you should re-check them.
Unity Firebase Analytics Setup: What You Need Before You Start
Prepare these items first.
| Requirement | What to check |
|---|---|
| Unity version | Firebase’s Unity setup page says to install Unity 2021 LTS or later, and notes that earlier versions may work but are not actively supported |
| Firebase project | A Firebase project connected to your app |
| App IDs | Your Android package name and iOS bundle ID, exactly as they appear in Unity |
| Test device | A real Android or iOS device for testing |
| Android | Google Play services must be up to date on the device for the Android SDK |
| iOS | Xcode and CocoaPods versions listed on Firebase’s pages for your SDK version |
Read the official Firebase Unity setup guide before you start, because the exact requirements depend on the SDK version you download.
If you are customizing a ready-made project, set your own package name first and keep it stable. Our guide to publishing a Unity source code game on Google Play explains why, and the Firebase registration must match it.
Step 1: Create a Firebase Project and Register Your App
In the Firebase console, create a project (or open an existing one), then click the Unity icon in the project overview to start the setup workflow. Select the build target you want to register, Android, iOS or both. Enter the Android package name and the iOS bundle ID from your Unity project, and optionally add a nickname.
If the package name in Firebase does not match the one in Unity, the configuration file will not work, so check the spelling and capitalization.
Step 2: Download the Config Files and Add Them to Unity
Download google-services.json for Android and GoogleService-Info.plist for iOS. Firebase warns that the file name must not have extra characters such as (2) at the end, which happens when you download the file twice. Move the files into the Assets folder of your Unity project, then return to the console and click Next.
Treat these files as part of your project configuration. If you share the project with a developer or a studio, make sure the Firebase project stays under your own account, so you keep control of the data.
Step 3: Import the Firebase Unity SDK and the Analytics Package
In the Firebase console, download the Firebase Unity SDK and unzip it. In Unity, choose Assets, then Import Package, then Custom Package, select FirebaseAnalytics.unitypackage and import it. Add other packages only if you need those products, for example Crashlytics or Remote Config, because every extra package adds size and complexity. Our Unity build size optimization guide explains how SDKs affect build size.
Firebase’s mobile library table notes that AdMob is distributed separately in the AdMob Unity plugin. If you also show ads, follow our guide to adding AdMob to a Unity game.
Step 4: Check Dependencies at Startup
On Android, the Firebase Unity SDK needs up-to-date Google Play services. Firebase’s documentation recommends checking and fixing dependencies before you use other SDK methods. The script below follows the pattern in the official guide and then gives you a safe place to log events. It is a starting point, not a production-complete system.
using UnityEngine;
using Firebase;
using Firebase.Analytics;
using Firebase.Extensions;
public class AnalyticsManager : MonoBehaviour
{
public static AnalyticsManager Instance { get; private set; }
private bool _ready;
private void Awake()
{
if (Instance != null) { Destroy(gameObject); return; }
Instance = this;
DontDestroyOnLoad(gameObject);
}
private void Start()
{
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
{
if (task.Result == DependencyStatus.Available)
{
_ready = true; // Firebase is safe to use from here on.
}
else
{
Debug.LogError($"Could not resolve all Firebase dependencies: {task.Result}");
}
});
}
public void LogLevelStart(string levelName)
{
if (!_ready) return;
FirebaseAnalytics.LogEvent("level_start", "level_name", levelName);
}
public void LogLevelComplete(string levelName, int seconds, int stars)
{
if (!_ready) return;
FirebaseAnalytics.LogEvent("level_complete", new Parameter[]
{
new Parameter("level_name", levelName),
new Parameter("duration_sec", seconds),
new Parameter("stars", stars)
});
}
public void LogScore(int score)
{
if (!_ready) return;
FirebaseAnalytics.LogEvent(FirebaseAnalytics.EventPostScore, FirebaseAnalytics.ParameterScore, score);
}
}
What the script does: it keeps one persistent object, waits until Firebase dependencies are available and then exposes small methods your game code calls. Firebase’s documentation shows the same LogEvent patterns for events with no parameters, with one parameter and with a parameter array. Test the script in your Unity and SDK version, and note that very early events can be skipped while the check is still running.
Step 5: Plan Your Events Before You Log Them
The most common analytics mistake is logging everything without a question in mind. Start with the questions you want answered: Do players finish the tutorial? Where do they quit? What do they buy? Do rewarded ads help?
Firebase’s documentation says Analytics automatically logs some events and user properties, and that you can set up to 25 different user properties and log up to 500 different event types. It also defines recommended events common to gaming apps, and says that logging suggested events with their prescribed parameters gives you the most detail in reports. Check the current list of recommended events and parameter names before you invent your own.
Use clear snake_case names and keep a written tracking plan in your team’s documentation. Our guide to mobile game UI/UX design best practices shows screens you may want to measure, such as tutorial steps and shop screens.
Step 6: Log Events from Your Game Code
Call your logging methods at moments that matter: when a level starts, when it ends, when the player opens the shop or when a reward is claimed. For purchases, log the event after your purchase is confirmed, as described in our Unity in app purchase setup guide, not when the player taps the button.
Keep parameters small and consistent. Firebase documents a general-purpose value parameter for accumulating a key metric such as revenue, distance, time or points. Custom parameters can also be included in data exported to BigQuery if your app is linked to a BigQuery project.
Step 7: Test with Logcat and DebugView
Do not trust the dashboard first. Firebase’s documentation says the dashboard updates periodically through the day, so use logging and DebugView for immediate checks.
Android logcat. Firebase’s events guide lists these commands to enable verbose logging and view events:
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC
DebugView. Normally, events are batched and uploaded about once an hour, to save battery and data. Firebase’s DebugView guide explains that debug mode uploads events with minimal delay on a development device. On Android, run the command below with your package name, and switch it off with the .none. command when you finish testing:
adb shell setprop debug.firebase.analytics.app YOUR_PACKAGE_NAME
adb shell setprop debug.firebase.analytics.app .none.
On iOS, add the -FIRDebugEnabled argument in Xcode under Arguments Passed On Launch, and -FIRDebugDisabled to turn it off. Then open DebugView in the Firebase console, select your device and play. The Seconds stream shows the last 60 seconds, and you can click an event to see its parameters. If an event has a firebase_error parameter, the SDK found a problem with an event or property.
Also review the Firebase guide to logging events and test the full list of events on a real device, as described in our Unity game QA checklist.
Step 8: Read the Data and Make Decisions
After DebugView confirms the events, release a build and let data collect. Look at tutorial completion, where players leave levels, what they do before they buy and whether rewarded ads lead to more sessions. Change one thing at a time, so you know which change caused a result. Small player numbers produce noisy data, so avoid big conclusions from a few users.
Privacy, Consent and Store Declarations
Analytics collects data about players, so it must appear in your privacy policy and in your store declarations. When you publish on Google Play, the Data safety form must describe what your app and its SDKs collect and share, as we explain in our release guide linked above. Some regions require consent before analytics or ads data are collected. Our AdMob guide covers Google’s consent tool, and the same principle applies to analytics: do not start collection before consent where it is required. Check Firebase’s current documentation for how to control collection in your SDK version, and ask a privacy professional if you are unsure. If your game targets children, rules are stricter, so read the relevant platform policies first.
A Hypothetical Example: Tracking Plan for a Casual Puzzle Game
This example is illustrative, not a real project. A small team wants to know whether new players understand the game and where they leave.
| Event | Parameters | Question it answers |
|---|---|---|
| tutorial_begin and tutorial_complete | step_count | Do players finish the tutorial? |
| level_start | level_name | Which levels do players try? |
| level_complete | level_name, duration_sec, stars | How long and how well do they play? |
| level_fail | level_name, reason | Where is the game too hard? |
| shop_open | source_screen | Which screens lead to the shop? |
| purchase_confirmed | product_id, value | What do players buy? |
| rewarded_ad_completed | placement | Which rewards players choose? |
The team logs only these events at first, tests each one in DebugView and reviews the data after two weeks. If you want to see Unity mobile projects built by our team, you can browse our 3D tennis game Unity project and our Car Stunt Simulator 2024 Unity project as examples of our work. We do not claim these projects use Firebase.
Troubleshooting: Firebase Analytics Events Not Showing
| Symptom | Likely cause | What to try |
|---|---|---|
| Nothing appears in the dashboard | Events are batched and the dashboard updates later | Use DebugView and logcat first |
| DebugView shows no device | Debug mode is not enabled or the package name is wrong | Run the debug command with the exact package name |
| Initialization fails on Android | Google Play services are missing or outdated | Check the dependency status and update services |
| Config file errors | Wrong file name or wrong package name | Remove extra characters like (2) and match IDs exactly |
| Events missing at app start | Logging before initialization finished | Wait for the dependency check |
| Events show firebase_error | Invalid event or parameter | Click the event and read the error in DebugView |
Common Mistakes in Unity Firebase Analytics Setup
- Logging without questions. Start from decisions, not from events.
- Package name mismatch between Unity and Firebase.
- Testing only in the Editor. Use a real device.
- Leaving debug mode on after testing.
- Inconsistent event names, such as level_start and LevelStart in different scripts.
- Logging purchases before confirmation.
- Forgetting privacy and Data safety updates.
- Adding every Firebase package and growing the build for no reason.
Conclusion
A reliable Unity Firebase Analytics setup means more than importing a package. Register your app with matching IDs, add the config files, import the Analytics package, check dependencies at startup, plan a small set of meaningful events, test with logcat and DebugView and handle privacy honestly. Check Firebase’s documentation before every release, because SDK and platform requirements change.
At GamePro Studio, we build Unity games, 3D art and game UI/UX for mobile, PC and VR. If you need help with your Unity Firebase Analytics setup or with planning what your game should measure, you can start with our Unity game developer hiring service.
Frequently Asked Questions (FAQs)
Do I need other Firebase products to use Analytics in Unity?
No. Analytics only needs FirebaseAnalytics.unitypackage. Some other products, such as Crashlytics and Remote Config, recommend adding Analytics for better results, but each product is optional.
How many events can I log?
Firebase’s documentation says you can log up to 500 different event types and set up to 25 user properties, with no limit on the total volume of events. Check the current limits in the official pages.
Why do my events not appear right away?
Events are batched and uploaded roughly once an hour, and reports update through the day. Use DebugView with debug mode enabled for immediate checks.
Should I use recommended events or custom events?
Use recommended events when one matches your need, with their prescribed parameters, because reports can show more detail. Use custom events for game-specific actions that no recommended event covers.
Does Firebase Analytics work with ads and purchases?
Yes, as separate integrations. Your game logs events from your own code at ad and purchase moments, and each integration has its own setup, like those in our AdMob and in-app purchase guides.