This event is triggered when a user purchases an item and completes their order.
ImportantDue 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,productsproperties are required to be non-empty.- The
emailproperty is required to be non-empty otherwise this event will not be tracked. - The
phoneshould 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.
- Example phone format:
- If
paymentMethodorcouponsproperties are not null, they must be non-empty. productId,skuIdproperties are required to be non-empty.productIdis the same asitemIdin trackViewItemskuIdis the same asfeedIdin trackSelectSKU
price,quantityproperties are required to be greater than or equal to 0.amount,tax,shippingproperties are required to be greater than or equal to 0.0.- If
totalDiscountproperty 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
Creating Customer
A customer object requires an email and accepts an optional phone. You could also pass the hashed email and phone.
// Only email
Customer customer = Customer.createCustomer(email = String)
// Enail & Phone
Customer customer = Customer.createCustomer(email = String, phone = Long)// Only email
let customer = Customer(email: String)
// Enail & Phone
let customer = Customer(email: String, phone = Int)// Only email
var customer = Customer.createCustomer(email: String);
// Enail & Phone
var customer = Customer.createCustomerWithPhone(
email: String,
phone: Int
);// Only email
const customer = Customer.createCustomer(email: string);
// Enail & Phone
const customer = Customer.createCustomerWithPhone(
email: string,
phone: number
);Also refer to creating Hashed Customer
Creating Order
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
)
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)
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.createCustomer(
email: String
);
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 = Customer.createCustomer(email: string)
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);