Event Tracking
Tracking Revenue
How to track Purchase Revenue
This event is used to track purchase revenue if you are not using Noctua In-App Purchase. If you are using Noctua In-App Purchase, this is not required.
if (purchaseResponse.Status == OrderStatus.completed)
{
Noctua.Event.TrackPurchase(
purchaseResponse.OrderId.ToString(),
0.1,
"USD",
//extra params is optional
new Dictionary<string, IConvertible>
{
{ "RoleId", "123" },
{ "ServerId", "456" },
{ "IngameItemId", "789" },
{ "IngameItemName", "Skin X" }
}
);
Debug.Log("Purchase was successful!");
}
else
{
Debug.LogError("Purchase failed: " + purchaseResponse.Status);
}
How to track Custom Event with Revenue
This event is used to track custom events with revenue, allowing revenue data to be displayed directly in the Adjust dashboard, as well as in Firebase and Facebook. For example, to track ad impression revenue, call it in the OnAdRevenuePaidEvent
callback. To track purchase revenue, call it in the purchase success callback.
Noctua.Event.TrackCustomEventWithRevenue("ad_impression", 0.1, "USD", new Dictionary<string, object>() {
{ "key", "value" }
});
Parameters
- eventName: The name of the event to track.
- revenue: The revenue of the event to track.
- currency: The currency of the event to track.
- parameters: A dictionary of parameters to track with the event.
How to track ad revenue
This event is used to track ad revenue, for example, call it in the OnAdRevenuePaidEvent
callback. To track ad revenue.
Example
Noctua.Event.TrackAdRevenue("source", 100, "USD", new Dictionary<string, object>() {
{ "MyParam", "MyValue" }
});
Parameters
- source: The source of the ad revenue. Use
admob_sdk
for AdMob orapplovin_max_sdk
for AppLovin MAX. - revenue: The revenue of the ad.
- currency: The currency of the ad revenue.
- parameters: A dictionary of parameters to track with the event.
Data Sources
Applovin
// Attach callbacks based on the ad format(s) you are using
MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
MaxSdkCallbacks.MRec.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
private void OnAdRevenuePaidEvent(string adUnitId, MaxSdk.AdInfo adInfo)
{
string currency = "USD" // Hardcoded
string platform = "AppLovin"
double revenue = adInfo.Revenue;
string networkSource = adInfo.NetworkName; // Display name of the network that showed the ad
string adUnit = adInfo.AdUnitIdentifier; // The MAX Ad Unit ID
string adFormat = adInfo.Placement; // The placement this ad's postbacks are tied to
//Example how to track ad revenue
Noctua.Event.TrackAdRevenue("applovin_max_sdk", revenue, currency, new Dictionary<string, object>() {
{ "platform", platform },
{ "networkSource", networkSource }
});
//Example how to track custom event with revenue
Noctua.Event.TrackCustomEventWithRevenue("ad_impression", revenue, currency, new Dictionary<string, object>() {
{ "platform", platform },
{ "networkSource", networkSource }
});
}
Admob
public void HandleAdPaidEvent(AdValue adValue)
{
// Revenue info
long valueMicros = adValue.Value;
double revenue = valueMicros / 1_000_000.0;
string currencyCode = adValue.CurrencyCode;
// Get response info from the ad format rewarded ad or other formats (interstitial, banner)
ResponseInfo responseInfo = rewardedAd.GetResponseInfo();
string responseId = responseInfo.GetResponseId();
// Get loaded adapter response info
AdapterResponseInfo loadedAdapterResponseInfo = responseInfo.GetLoadedAdapterResponseInfo();
string adSourceName = loadedAdapterResponseInfo.AdSourceName;
long latencyMillis = loadedAdapterResponseInfo.LatencyMillis;
//Example how to track ad revenue
Noctua.Event.TrackAdRevenue("admob_sdk", revenue, currencyCode, new Dictionary<string, object>() {
{ "latencyMillis", latencyMillis },
{ "adSourceName", adSourceName }
});
//Example how to track custom event with revenue
Noctua.Event.TrackCustomEventWithRevenue("ad_impression", revenue, currencyCode, new Dictionary<string, object>() {
{ "latencyMillis", latencyMillis },
{ "adSourceName", adSourceName }
});
}
Sources
- AppLovin: Impression-Level User Revenue API
- AdMob: Implement a Paid Event Handler