#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.

You can use these methods to include your purchase data in TelemetryDeck:

  • Use the TelemetryDeck Swift SDK directly
  • If you’re already using RevenueCat, you can use the RevenueCat Integration
  • If you’re using FreemiumKit, you can connect that to TelemetryDeck

See the sections below for a detailed description.

Using the TelemetryDeck Swift SDK

If you’re using the TelemetryDeck Swift SDK, tracking purchases is incredibly simple. Just call the convenience method when you receive a StoreKit transaction:

TelemetryDeck.purchaseCompleted(transaction: transaction)

That’s it! This method automatically:

  • Extracts the price from the transaction
  • Converts the currency to USD (using hard-coded exchange rates)
  • Determines if it’s a subscription or one-time purchase
  • Includes the storefront country and currency codes
  • Sends the properly formatted signal to TelemetryDeck

Using TelemetryDeck with RevenueCat

If you use RevenueCat, you can use our RevenueCat Setup Guide.

Using FreemiumKit

If you use FreemiumKit, just add their SDKs .onPurchaseCompleted view modifier to your main view. It passes the transaction parameter to the closure, which you can directly pass to TelemetryDeck.purchaseCompleted(transaction: transaction). Read the related section in their setup guide to learn more.

Manual Signal Structure for Other Platforms

If you’re reporting purchases from other platforms (Android, Web, etc.), you’ll need to manually construct and send the purchase signal with the following structure:

Required Fields

  • Event name: Must be TelemetryDeck.Purchase.completed
  • floatValue: The purchase amount in USD

To get more detailed insights, include these additional parameters:

  • TelemetryDeck.Purchase.type: Either subscription or one-time-purchase
  • TelemetryDeck.Purchase.countryCode: The country code of the storefront
  • TelemetryDeck.Purchase.currencyCode: The currency code of the storefront

Example Manual Implementation (Swift)

Here’s what the manual implementation looks like if you need to customize it or understand what the convenience method does internally:

// Convert price to USD first (you need to handle currency conversion)
let priceInUSD = convertToUSD(transaction.price, from: transaction.currencyCode)

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: priceInUSD
)

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