-
Notifications
You must be signed in to change notification settings - Fork 4
Affiliate program
Denis edited this page Feb 14, 2022
·
2 revisions
Google Analytics collects usage and behavior data for your app.
Add the Firebase Unity SDK (specifically, FirebaseAnalytics.unitypackage
) to your Unity project.
To collect user loss analytics, you need to add the following script to the project.
The script automatically sends the transition to a new scene.
If your game has a single game scene, call a UserProgressAnalytics.Send()
method with more information about the user's current progress.
using UnityEngine;
using UnityEngine.SceneManagement;
using Firebase.Analytics;
namespace CAS
{
public static class UserProgressAnalytics
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
public static void Init()
{
SceneManager.activeSceneChanged += OnActiveSceneChanged;
}
private static void OnActiveSceneChanged(Scene current, Scene next)
{
Send(next.name);
}
public static void Send(string progress)
{
Parameter[] fParams = new Parameter[]
{
new Parameter(FirebaseAnalytics.ParameterScreenClass, "game.scene"),
new Parameter(FirebaseAnalytics.ParameterScreenName, progress)
}
FirebaseAnalytics.LogEvent(FirebaseAnalytics.EventScreenView, fParams);
}
}
}
- Project Setup
- Configuring SDK
- Include Android
- Include iOS
- Additional mediation steps
- App-ads.txt🔗