Superfine SDK Unity¶
Introduction¶
The Superfine SDK for Unity provides a comprehensive solution for integrating revenue tracking and reporting into your Unity applications. This guide will walk you through the setup and configuration process.
Download¶
Setup¶
-
Import Unity Package
Download the SuperfineSDK zip file, unzip it, and copy the extracted files into yourPackages
folder.⚠️ Important: The SDK requires the External Dependency Manager to function properly. You can remove or modify these dependencies to match your application's version requirements. Download the External Dependency Manager from here.
-
Get App Information
Go to the project section on the Superfine.org dashboard, select your project, and copy the Project ID and Project Secret. -
Update Superfine Settings
From the menu, select Superfine/Edit Settings to update your Project ID and Project Secret. -
Initialize SDK
Add the following code to initialize the SDK (this can be placed in theAwake
function of a new component).
void Awake()
{
SuperfineSDKSettings settings = SuperfineSDKSettings.LoadFromResources().Clone();
settings.autoStart = false;
// Initialize SuperfineSDK.
SuperfineSDK.Initialize(settings, OnInitialized);
// Note: Call SuperfineSDK.Start(); after MMP and Mediation SDK initialization.
SuperfineSDK.Start();
}
// Callback after Superfine initialization is complete
void OnInitialized()
{
}
autoStart
is set to false
, you can manually start the SDK as follows:
settings.autoStart = false;
SuperfineSDK.Initialize(settings, OnInitialized);
// Start SuperfineSDK when needed.
SuperfineSDK.Start();
⚠️ Important: You should call
Unity.SuperfineSDK.Initialize();
after MMP and Mediation SDK initialization.
Link Events to MMP (Required)¶
We support MMPs such as Appsflyer, Adjust, Singular, and Tenjin. Here is how to do it:
1. Send Linking Event¶
Setting the link event using Customer User ID: Make sure you call this function only once after the Superfine SDK is successfully initialized, and MMP is successfully initialized.
Example:
void OnInitialized()
{
string sfid = Superfine.Unity.SuperfineSDK.GetUserId();
int sendLinkEventCount = PlayerPrefs.GetInt("LinkEventWithMMP", 0);
if (!string.IsNullOrEmpty(sfid) && sendLinkEventCount == 0)
{
// For Appsflyer
Dictionary<string, string> appsflyerData = new Dictionary<string, string>();
appsflyerData.Add("sf_link_uid", sfid);
AppsFlyerSDK.AppsFlyer.setCustomerUserId(sfid);
AppsFlyerSDK.AppsFlyer.sendEvent("sf_link_uid", appsflyerData);
// For Singular
Dictionary<string, object> singularData = new Dictionary<string, object>
{
{ "sf_link_uid", sfid }
};
SingularSDK.SetCustomUserId(sfid);
SingularSDK.Event(singularData, "sf_link_uid");
// For Tenjin
BaseTenjin instance = Tenjin.getInstance(TENJINKEY);
instance.SetCustomerUserId(sfid);
instance.SendEvent("sf_link_uid");
// For Adjust, set the sf_link_uid in the Adjust server and get the token
Adjust.addSessionCallbackParameter("userId", sfid);
AdjustEvent adjustEvent = new AdjustEvent(SF_LINK_UID_TOKEN);
Adjust.trackEvent(adjustEvent);
// Ensure this is sent only once
PlayerPrefs.SetInt("LinkEventWithMMP", 1);
}
}
2. Set Callback Events¶
Appsflyer¶
Set callback event
Go to Appsflyer > Active Partner > Pick the app
Map the sf_link_uid
event for All media sources, including Values & Revenue.
Adjust¶
Set sf_link_uid
event
Go to App View > All Apps > Pick your app > Event > Add Event
Add the sf_link_uid
event.
Then, copy the Token.
Use this Token in the code:
Example:
Adjust.addSessionCallbackParameter("userId", sfid);
AdjustEvent adjustEvent = new AdjustEvent(Token);
Adjust.trackEvent(adjustEvent);
Singular¶
No extra steps needed
Tenjin¶
Set callback event
Go to Tenjin > Configure > Apps > Callbacks, and search for Superfine in the Channels and Partners section.
Add the event sf_link_uid
to the callback, ensuring the user filter is configured for All Users.
Ad Revenue Auto-Tracking¶
These events are used to track ad revenue from your app. We support automatic ad revenue tracking.
Our SDK provides ad revenue reporting support through add-on classes. You can receive detailed reports by implementing the appropriate class based on your chosen mediation platform and registering for events.
Currently, we support the following mediation platforms:
- MAX Mediation (AppLovin)
- Appodeal (both UMP and Manual versions)
- IronSource Mediation
- Google AdMob Mediation
1. MAX Mediation (AppLovin)¶
- Integration: Add the AppLovin Helper add-on to your project by navigating to Superfine > Add-ons > AppLovin.
- Event Registration: Start logging revenue and impressions by calling
SuperfineSDKApplovin.RegisterPaidEvent()
.
To stop logging, callSuperfineSDKApplovin.UnregisterPaidEvent()
or do so when your manager class is destroyed.
2. Appodeal Mediation¶
- Integration: Add the Appodeal Helper add-on to your project by navigating to:
- Superfine > Add-ons > Appodeal (UMP) (for the UMP version).
- Superfine > Add-ons > Appodeal (Manual) (for the Manual version).
- Event Registration: Start logging revenue and impressions by calling
SuperfineSDKAppodeal.RegisterPaidEvent()
.
To stop logging, callSuperfineSDKAppodeal.UnregisterPaidEvent()
or do so when your manager class is destroyed.
3. IronSource Mediation¶
- Integration: Add the IronSource Helper add-on to your project by navigating to Superfine > Add-ons > IronSource.
- Event Registration: Start logging revenue and impressions by calling
SuperfineSDKIronSource.RegisterPaidEvent()
.
To stop logging, callSuperfineSDKIronSource.UnregisterPaidEvent()
when done or when your manager class is removed.
4. Google AdMob Mediation¶
- Integration: Add the AdMob Helper add-on to your project by navigating to Superfine > Add-ons > AdMob.
-
Event Registration: You must register events for all ad placements:
-
Banner Ads:
-
Interstitial Ads:
-
Rewarded Video Ads:
-
Rewarded Interstitial Ads:
-
App Open Ads:
-
Ad Revenue Tracking:
IAP Revenue Recognition¶
The SuperfineSDKUnityIAP
class simplifies the process of sending In-App Purchase (IAP) receipt events.
Ensure you are using the Unity IAP package for this functionality.
- Integration: Add the Unity IAP Helper add-ons to your project by navigating to Superfine > Add-ons > UnityIAP.
- Sending Events: Call
Superfine.Unity.SuperfineSDKUnityIAP.LogIAPReceipt(Product p)
when a purchase is successfully completed using the Unity IAP plugin.
Example:
// Callback function for successful purchase
private void ProcessProductFinal(Product p, string receipt = null)
{
// Implement your logic here
// Log the first purchase event
Superfine.Unity.SuperfineSDK.LogIAPResult(p.definition.id, (double)(p.metadata.localizedPrice), 1, p.metadata.isoCurrencyCode, true);
// Use Unity IAP helper to send the receipt event for LTV calculation of renewing purchases
Superfine.Unity.SuperfineSDKUnityIAP.LogIAPReceipt(p);
}
Wallet Events - For On-Chain Revenue Recognition¶
- LogWalletLink
void LogWalletLink(const String wallet, const String type = "ethereum");
Description: Call this method when you want to link the user's wallet address.
Parameters | |
---|---|
wallet |
String: Cannot be null. The wallet address you want to log the linking event for |
type |
String: Default is "ethereum". The chain of the wallet address |
Example:
//Link wallet address "ronin:50460c4cd74094cd591455cad457e99c4ab8be0" in the "ronin" chain
SuperfineSDK.LogWalletLink("ronin:50460c4cd74094cd591455cad457e99c4ab8be0", "ronin");
void LogWalletUnlink(const String wallet, const String type = "ethereum");
Description: Call this method when you want to unlink the user's wallet address.
Parameters | |
---|---|
wallet |
String: Can't be null. The wallet address you want to log the unlinking event for. |
type |
String: Default is "ethereum". The chain of the wallet address. |
Example:
//Unlink wallet address "ronin:50460c4cd74094cd591455cad457e99c4ab8be0" in "ronin" chain
SuperfineSDK.LogWalletUnlink("ronin:50460c4cd74094cd591455cad457e99c4ab8be0", "ronin");
Additional Revenue Sources¶
You can log addional revenue by using
void LogIAPResult(string pack, float price, int amount, string currency, bool isSuccess);
Description: Call this method when the user attempts to buy an IAP item.
Parameters | |
---|---|
pack |
String: Can't be null. The unique identifier of the purchased item or pack. |
price |
Float: Can't be null. The price of the item or pack. |
amount |
Integer: Can't be null. The quantity of the purchased item or pack. |
currency |
String: The currency code (e.g., "USD", "EUR") corresponding to the revenue. |
isSuccess |
Boolean: Can't be null. True if the purchase was successful. False if the purchase failed. |
Example: