Purchase Events

GetSocial SDK supports tracking purchases users make in your application. The gathered data is shown in Revenue Analytics section.

Automatic tracking

In order to automatically track purchases, follow the setup guide here.

Manual tracking

If you don’t want to use automated tracking, you can report purchase events on your own.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
val purchaseData = new PurchaseData()
    .withProductId(product_id)
    .withProductTitle(product_title)
    .withProductType(product_type) // Item or subscription
    .withPrice(product_price)
    .withPriceCurrency(price_currency)
    .withPurchaseId(purchase_id)
    .withPurchaseDate(purchase_date)

if (Analytics.trackPurchaseEvent(purchaseData)) {
    // Successfully tracked purchase data
} else {
    // Failed to track purchase data
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
var purchaseData = PurchaseData()
purchaseData.productId = // product id
purchaseData.productType = ProductType.Item.rawValue // item or subscription
purchaseData.productTitle = // product title
purchaseData.price = // product price
purchaseData.priceCurrency = // price currency
purchaseData.purchaseDate = // purchase date
purchaseData.transactionIdentifier = // unique transaction id

if (Analytics.trackPurchase(purchaseData)) {
    // Successfully tracked purchase data 
} else {
    // Failed to track purchase data
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
var purchaseData = new PurchaseData();
purchaseData.ProductId = // product id
purchaseData.PurchaseType = // item or subscription
purchaseData.ProductTitle = // product title
purchaseData.Price = // product price
purchaseData.PriceCurrency = // price currency
purchaseData.PurchaseDate = // purchase date
purchaseData.PurchaseId = // unique transaction id

if (Analytics.TrackPurchase(purchaseData))
{
    // Successfully tracked purchase data 
}
else
{
    // Failed to track purchase data
}

Give us your feedback! Was this article helpful?

😀 🙁