Integrating Firebase (Google) Analytics with Unity for Android and iOS

Integrating Firebase (Google) Analytics with Unity for Android and iOS

Import the Firebase Analytics Unity Plugin
1) Download the FirebaseAnalytics-12.0.0.unitypackage
2) Import the .unitypackage file by selecting the Unity menu option Assets > Import Package > Custom Package and import all items.

Initialise the SDK
1) Download the custom scripts & prefabs here.
2) Drag '_FirebaseAnalyticsInit.prefab' to Splash Scene to initialise the scripts only once.

3) Drag Firebase Console downloaded files 'google-services.json', 'GoogleService-Info.plist' to Assets


Log events
The following example level logs events:
StartFirebaseAnalytics.LogEvent("level_start_" + GameData.GetCurrentLevel());
Fail: FirebaseAnalytics.LogEvent("level_fail_" + GameData.GetCurrentLevel());
FinishFirebaseAnalytics.LogEvent("level_finish_" + GameData.GetCurrentLevel());


GitHub Commit: Files too large

Issue: The following files are over 100MB. If you commit these files, you will no longer be able to push this repository to
Open GitHubDesktop > Repository > Open in Terminal
1) git lfs track "*.so"
2) git add path/to/ (Right click on .so Repository file in GitHub Desktop > Reveal in finder)
3) git commit -m "added firebase"
4) Push Origin in GitHub Desktop Current Repository

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.