A simple Facebook and Game Analytics integration for Unity on Android and iOS.
Should work on devices using Android 5.1+ or iOS 14.5-
Not tested on iOS 14.5+ devices or using Xcode 13. I was limited to build on Xcode 12.5 up to iOS 14.5 (simulator).
Unity
Unity 2020.3 (recommended)
Unity 2019.4+
Unity 2018.4 (not tested)
iOS Build
- Xcode 12.5+ (recommended)
- Cocoapods
Android Build
- For Unity 2020.3+ there is no requirements other than Android Build support properly configured.
- For version below 2020.3 you will need to export the project and build using Android Studio.
The nano sauce has inside himself some 3rd party sdk`s and plugins, you cannot have them on your current project. If you have any of them, please remove from you project.
- Facebook SDK
- GameAnalytics
- ExternalDependencyManager
- Install the nano-sauce .unitypackage into your unity project.
- After installation the External Dependency Manager should ask to enable Auto Resolution to resolve his libraries (or will start to auto resolve), accept and wait.
Go to NanoSauce > Settings in the Unity top menu.
- Fill App ID in Facebook section with your facebook application id.
- Fill in Game Analytics Section the Game Key and Secret Key for the desired (or both) platform.
- Hit Apply.
Go to NanoSauce > Settings in the Unity top menu.
- Change the Cohorts value for the amount of A/B test cohorts that you want.
- You should see a list of Cohort ID, fill each one with a different ID to identify the desired cohort.
- Hit Apply.
You don`t need to initialize anything, just call the desired methods in your game.
You can track the progression of the player using some provided methods.
using com.vhndev.nanosauce.analytics;
- Call NanoSauceAnalytics.RegisterGameStart() when the level start.
- Call NanoSauceAnalytics.RegisterGameLose() when the level is lost.
- Call NanoSauceAnalytics.RegisterGameWin() when the level is won.
Track a custom event anywhere in your game by calling NanoSauceAnalytics.RegisterCustomEvent(). Can be useful for tracking goals inside the game or anything else.
You should pass an string as argument and an float as optional event value.
Nano-sauce A/B tests works using GameAnalytics custom dimension.
You can make A/B tests using cohorts (see setup on top). Call NanoSauceAnalytics.GetCurrentCohortID() and you will be returned with the sorted cohort.
using com.vhndev.nanosauce.analytics;
...
string cohortID = NanoSauceAnalytics.GetCurrentCohortID();
if (cohortID == "A")
Player.StartWeak():
else if (cohortID == "B")
Player.StartStrong();
In GameAnalytics you can visualize the cohort of each player by his custom_01 tracked by default on any event. It`s possible to use the Dimensions > Custom 1 filter to visualize in a graph and compare data.
You can found an complete sample implementation at folder NanoSauce/Sample that includes a scene and code.
Before you start an Android Build make sure to Resolve the Android External Dependency Manager, you can do that by going into unity top menu Assets > External Dependency Manager > Android > Android Resolver > Resolve
In Unity 2020.3+ you just need to build using Unity. For versions below you need to Export Project open it on Android Studio update the gradle plugin when asked and build here.
Thanks Facebook SDK 11
After the xcode project has been build up, don`t open the .xcproject extension file, use the .xcworkspace extension file to open the Xcode Project.
If .xcworkspace file does not exist, try running the terminal command pod install
in the project folder.