Skip to content

Logging purchases

Record in-app purchases so that you can track your revenue over time and across revenue sources and 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, custom attributes, and purchase events in our best practices, as well as our notes on event naming conventions.

Tracking purchases and revenue

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

1
AppDelegate.braze?.logPurchase(productID: "product_id", currency: "USD", price: price)
1
2
3
[AppDelegate.braze logPurchase:"product_id"
                      currency:@"USD"
                         price:price];
  • Supported currency symbols include: USD, CAD, EUR, GBP, JPY, AUD, CHF, NOK, MXN, NZD, CNY, RUB, TRY, INR, IDR, ILS, SAR, ZAR, AED, SEK, HKD, SPD, DKK, and more.
    • Any other provided currency symbol will result in a logged warning and no other action taken by the SDK.
  • The product ID can have a maximum of 255 characters
  • Note that if the product identifier is empty, the purchase will not be logged to Braze.

Adding properties

You can add metadata about purchases by passing a Dictionary populated with Int, Double, String, Bool, or Date values.

Refer to the iOS class documentation for additional details.

Adding quantity

You can add a quantity to your purchases if customers make the same purchase multiple times in a single checkout. You can accomplish this by passing in an Int for the quantity.

  • A quantity input must be in the range of [0, 100] for the SDK to log a purchase.
  • Methods without a quantity input will have a default quantity value of 1.

Refer to the iOS class documentation for additional details.

1
AppDelegate.braze?.logPurchase(productId: "product_id", currency: "USD", price: price, quantity: quantity, properties: ["key1":"value1"])
1
2
3
4
5
[AppDelegate.braze logPurchase:productId
                      currency:@"USD"
                         price:price
                      quantity:quantity
                    properties:@{@"checkout_id" : self.checkoutId}];

Log purchases at the order level

If you want to log purchases at the order level instead of the product level, you can use order name or order category as the product_id. Refer to our purchase object specification to learn more.

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.

HOW HELPFUL WAS THIS PAGE?
New Stuff!