trackPurchase

This event is triggered when a user purchases an item and completes their order.

🚧

Important

Due to the importance of the Purchase event, it's imperative that all of its attributes (Invoice, Customer, Product, Order) be correctly set.

  • If Purchase event attributes are not entered correctly, the following error may be generated in your project's logs: "Unfortunately, event "Purchase" hasn't been tracked since you have provided a nullable parameter or a not valid one."
  • orderId, goal, products properties are required to be non-empty.
  • The phone should be passed in the following format: (country code)(phone number)
    • Example phone format: 13303332222
    • If the phone is deemed not valid, the following warning log will be emitted: Unfortunately, event hasn't been tracked since you have provided a nullable parameter or a not valid one.
  • If paymentMethod or coupons properties are not null, they must be non-empty.
  • productId, skuId properties are required to be non-empty.
  • price, quantity properties are required to be greater than or equal to 0.
  • amount, tax, shipping properties are required to be greater than or equal to 0.0.
  • If totalDiscount property is not null, it must be greater than or equal to 0.0.

Supported Currency Values

USD, KRW, AED, LTL, ARS, MAD, AUD, MXN, BGN, MYR, BOB, NOK, BRL, NZD, CAD, PEN, 
CHF, PHP, CLP, PKR, CNY, PLN, COP, RON, CZK, RSD, DKK, RUB, EGP, SAR, EUR, SEK, 
GBP, SGD, HKD, THB, HRK, TRY, HUF, TWD, IDR, UAH, ILS, VEF, INR, VND, JPY, ZAR

Implementation

val couponList = mutableListOf<String>()
couponList.add("TestCoupon")

val products = mutableListOf<Product>()
val product = Product(
    productId = String,
    skuId = String,
    price = Double,
    quantity = Long
)
products.add(product)

val invoice = Invoice(
    amount = Double,
    tax = Double,
    shipping = Double,
    totalDiscount = Double?,
    currency = Currency
)

val customer = Customer.createCustomer(
    customerEmail = String,
    customerPhone = Long
)

val order = Order(
    orderId = String,
    invoice = invoice,
    paymentMethod = String?,
    products = products,
    customer = customer,
    couponList = couponList,
    goal = String
)
Wunderkind.getInstance().trackPurchase(order)
let invoice = Invoice(
    amount: Decimal,
    tax: Decimal,
    shipping: Decimal,
    totalDiscount: Decimal?,
    currency: Currency)

let customer = Customer(
    email: String,
    phone: String?)

let product = Product(
    productId: String,
    skuId: String,
    price: NSDecimalNumber,
    quantity: Int64)

let order = Order(orderId: "TestOrderId", invoice: invoice, paymentMethod: String?, products: [product], customer: customer, coupons: [String]?, goal: String)

Wunderkind.shared.trackPurchase(order: order)
var customer = Customer.createCustomerWithPhone(
    email: String, 
    phone: Int
);

var invoice = Invoice(
    amount: double,
    shipping: double,
    currency: Currency,
    tax: double,
    totalDiscount: double?
);

var product = Product(skuId: String, price: double, quantity: int, productId: String);

var myOrder = Order(orderId: String, invoice, paymentMethod: String?, products, customer, couponList: List<String>?, goal: String)
Wunderkind().trackPurchase(myOrder);
let product = new Product(
    skuId: string,
    price: number,
    quantity: number,
    productId: string
)

let customer = new Customer(string email, string phone)

let invoice = new Invoice(
    amount: number,
    shipping: number,
    currency: Currency,
    tax: number,
    totalDiscount?: number
)

let order = new Order(coupons?: string[]; orderId: string; invoice, customer, products: Product[], goal: string, paymentMethod?: string);

Wunderkind.trackPurchase(order);