#docs #articles #setup #beginner #insights #presets

Setting Up the 'Purchases' Preset to Get Live Purchase Data

TelemetryDeck ships with a set of insights that can be useful to track your revenue within the last few hours with live purchase data. Here's how to set them up.

Why Track Purchases?

If you are offering In-App Purchases in your app, you might have noticed some delay in officially reported purchase stats. For example, App Store Connect charts do not offer any purchase data for the last 3 hours. Such a delay can be annoying sometimes such as at the day of your app launch or a specific live event related to your app. On top of that, App Store Connect in particular signs you out of your account regularly, making it annoying to quickly look up purchase statistics.

That’s why you might want to set up a signal in your application to track purchases in your app through TelemetryDeck with just a couple of seconds delay, providing you with the live data you want.

Sending the Signal

To report purchases to TelemetryDeck, send the event name TelemetryDeck.Purchase.completed with the floatValue parameter set to the USD amount the user purchased. For example, using the Swift SDK you can get the price from StoreKit.Transaction like so:

let priceValue = NSDecimalNumber(decimal: transaction.price ?? Decimal()).doubleValue

TelemetryDeck.signal("TelemetryDeck.Purchase.completed", floatValue: priceValue)

The Swift SDK ships with a more convenient API that handles reading the price from the StoreKit transaction and converting to USD (with hard-coded non-live currency conversion) for you like so:

TelemetryDeck.purchaseCompleted(transaction: transaction)

Attaching the Payload

Optionally (but recommended), there are two additional payload keys that will give you additional insights:

  • TelemetryDeck.Purchase.type: Pass either subscription or one-time-purchase to see the type distribution.
  • TelemetryDeck.Purchase.countryCode: Pass the country code of the storefront to see the country distribution.
  • TelemetryDeck.Purchase.currencyCode: Pass the currency code of the storefront to see currency distribution.

In Swift getting all values and sending them looks like this:

TelemetryDeck.signal(
  "TelemetryDeck.Purchase.completed",
  parameters: [
    "TelemetryDeck.Purchase.type": transaction.subscriptionGroupID != nil ? "subscription" : "one-time-purchase",
    "TelemetryDeck.Purchase.countryCode": transaction.storefrontCountryCode,
    "TelemetryDeck.Purchase.currencyCode": transaction.currencyCode ?? "???"
  ],
  floatValue: NSDecimalNumber(decimal: transaction.price ?? Decimal()).doubleValue
)

Effect on Privacy & App Tracking Transparency

If you are using a 3rd-party service like RevenueCat, you don’t need to change your privacy labels at all because you’re sending way less data to TelemetryDeck than you are already to those services. So if you’ve followed their guides, you should be good.

If you aren’t using a 3rd-party library, you are now sending purchase history data to TelemetryDeck. So make sure to mark the checkbox for “Analytics” in the “Purchase History” entry in your App Privacy page.

You can answer all subsequent questions with “No” because we neither link collected data to the users identity, nor do we use them for tracking purposes.

When all is configured your “Purchases” entry in your App Privacy page should end up looking like this:

Purchases entry with only 'Used for Analytics' in the box