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.
If you pass in a value of 10 USD
, and a quantity of 3
then that will log to the user’s profile as 3 purchases of 10 dollars for a total of 30 dollars. Quantities must be less than or equal to 100. Values of purchases can be negative.
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.