Skip to content

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.

Android

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

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

iOS

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
GetSocialPurchaseData *purchaseData = [GetSocialPurchaseData new];
purchaseData.productId = // product id
purchaseData.productType = Item; // 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 ([GetSocial trackPurchaseEvent:purchaseData]) {
    // Successfully tracked purchase data 
} else {
    // Failed to track purchase data
}

Unity

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var builder = PurchaseData.CreateBuilder();
builder.WithProductId(_productId); 
builder.WithProductTitle(_productTitle);
builder.WithPriceCurrency(_priceCurrency);
builder.WithPrice(float.Parse(_priceStr));
builder.WithProductType(PurchaseData.ProductType.Item); // Item or subscription
builder.WithPurchaseDate(_purchase_date);
builder.WithPurchaseId(_purchase_id);

if (GetSocial.TrackPurchaseEvent(builder.Build()))
{
    // Successfully tracked purchase data 
} else 
{
    // Failed to track purchase data
};

Give us your feedback! Was this article helpful?

😀 🙁