Track Purchase Event
To track a purchase event in Unity, you will use the TrackPurchaseEvent
function. The following example demonstrates how to track a purchase event from a Unity script.
Method Signature:
public void TrackPurchaseEvent(string orderId, double purchaseAmount, string currency, Dictionary<string, string> parameters = null);
Explanation:
Calling the
TrackPurchaseEvent
Method:The
TrackPurchaseEvent
method is called on theactivity
object with the order ID"order123"
, purchase amount49.99
, currency"USD"
, and no additional parameters (null
).
Adding Parameters
If you need to pass additional parameters to the TrackPurchaseEvent
function, you can modify the call to include a dictionary of parameters.
Modified Example Script:
// Without parameters
NoctuaGame.TrackPurchaseEvent("12345", 0.99f, "USD", null);
// With parameters
Dictionary<string, string> params = new Dictionary<string, string>
{
{ "payment_method", "credit_card" },
{ "customer_type", "new" }
};
NoctuaGame.TrackPurchaseEvent("12345", 0.99f, "USD", params);
Explanation:
Dictionary Creation:
A dictionary of parameters is created with key-value pairs.
Calling
TrackPurchaseEvent
with Parameters:The
TrackPurchaseEvent
method is called with the order ID, purchase amount, currency, and the dictionary of parameters.
Last updated