Logging Purchases

Record in-app purchases so that you can track your revenue over time and across revenue sources, as well as segment your users by their lifetime value.

Braze supports purchases in multiple currencies. Purchases that you report in a currency other than USD will be shown in the dashboard in USD based on the exchange rate at the date they were reported.

Before implementation, be sure to review examples of the segmentation options afforded by Custom Events vs. Custom Attributes vs Purchase Events in our Analytics Overview.

Tracking Purchases & Revenue

To use this feature, add this method call after a successful purchase in your app:

1
2
3
4
5
6
Appboy.getInstance(context).logPurchase(
   String productId,
   String currencyCode,
   BigDecimal price,
   int quantity
);
1
2
3
4
5
6
Appboy.getInstance(context).logPurchase(
  productId: String,
  currencyCode: String,
  price: BigDecimal,
  quantity: Int
)

If the product Identifier is empty, the purchase will not be logged to Braze. See the Javadoc for more information.

Adding Properties

You can add metadata about purchases by passing a Braze Properties object with your purchase information.

Properties are defined as key-value pairs. Keys are String objects and values can be String, int, float, boolean, or Date objects.

1
2
3
AppboyProperties purchaseProperties = new AppboyProperties();
purchaseProperties.addProperty("key", "value");
Appboy.getInstance(context).logPurchase(..., purchaseProperties);
1
2
3
val purchaseProperties = AppboyProperties()
purchaseProperties.addProperty("key", "value")
Appboy.getInstance(context).logPurchase(..., purchaseProperties)

See the Javadoc for more information.

Reserved Keys

The following keys are RESERVED and CANNOT be used as Purchase Properties:

  • time
  • product_id
  • quantity
  • event_name
  • price
  • currency

REST API

You can also use our REST API to record purchases. Refer to the User API documentation for details.

*Implementation Examples

See PreferencesActivity.java and MainFragment.java in the Droidboy sample app.

WAS THIS PAGE HELPFUL?
New Stuff!