Skip to content


Logging purchases for iOS

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
2
3
[[Appboy sharedInstance] logPurchase:@"your product ID"
inCurrency:@"USD"
atPrice:[[[NSDecimalNumber alloc] initWithString:@"0.99"] autorelease]];
1
Appboy.sharedInstance()?.logPurchase("your product ID", inCurrency: "USD", atPrice: NSDecimalNumber(string: "0.99"))
  • 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 either passing an event property array or by passing an NSDictionary populated with NSNumber, NSString, or NSDate 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 NSUInteger 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.
  • Methods with a quantity input have no default value, and must receive a quantity input for the SDK to log a purchase.

Refer to the iOS class documentation for additional details.

1
2
3
4
[[Appboy sharedInstance] logPurchase:@"your product ID"
inCurrency:@"USD"
atPrice:[[[NSDecimalNumber alloc] initWithString:@"0.99"] autorelease]
withProperties:@{@"key1":"value1"}];
1
Appboy.sharedInstance()?.logPurchase("your product ID", inCurrency: "USD", atPrice: NSDecimalNumber(string: "0.99"), withProperties: ["key1":"value1"])

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!