Docs
grovs.io Start for free

Revenue

Track in-app purchases and custom payments with the Grovs React Native SDK.

Log purchases to attribute revenue to links and campaigns, and see ARPU, LTV and product and platform breakdowns in the dashboard. Revenue tracking is in beta.

Setup

1. Enable revenue tracking in the dashboard

  1. In the Grovs dashboard, go to Analytics → Revenue.
  2. Click Enable Revenue Tracking. Only instance admins can turn it on or off.

See Revenue for the dashboard and Goals for revenue goals.

2. Configure platform notifications

Logging purchases

Platform store purchases

logInAppPurchase takes an object with one platform-specific field. Each platform ignores the other's:

  • iOS: transactionId, the StoreKit 2 transaction ID as a decimal string.
  • Android: originalJson, the Google Play Billing purchase's originalJson string.
typescript
import { Platform } from 'react-native';
import Grovs from 'react-native-grovs-wrapper';
 
try {
    const success = await Grovs.logInAppPurchase(
        Platform.OS === 'ios'
            ? { transactionId: transaction.id }        // StoreKit 2 transaction ID
            : { originalJson: purchase.originalJson }   // Play Billing purchase JSON
    );
    console.log('Purchase tracked:', success);
} catch (error) {
    console.error('Error tracking purchase:', error);
}

The wrapper rejects with an error if the current platform's field is missing, or if transactionId isn't a numeric string on iOS. The resolved boolean differs per platform:

  • iOS: false means the native SDK didn't accept the purchase: the ID isn't a 64-bit integer, or the device runs iOS 14 or earlier (StoreKit 2 needs iOS 15). Only the ID is sent; the backend resolves product, price and currency. An ID already logged on the device is skipped.
  • Android: true as soon as the JSON reaches the native SDK; it doesn't confirm backend acceptance. The SDK reads the product ID and purchase token; the backend verifies the purchase, fills in price and currency and de-duplicates on purchase token.

Log each purchase once, right after it completes. (In wrapper 1.x this method took a plain string; see the 3.0 upgrade guide.)

Custom purchases

For purchases through Stripe, PayPal or any non-store system:

typescript
try {
    const success = await Grovs.logCustomPurchase(
        'buy',              // type: 'buy' | 'cancel' | 'refund'
        999,                // priceInCents: $9.99
        'USD',              // currency code
        'premium_monthly',  // product identifier
    );
    console.log('Custom purchase tracked:', success);
} catch (error) {
    console.error('Error:', error);
}

Parameters:

ParameterTypeDescription
typeTransactionType'buy', 'cancel' or 'refund'
priceInCentsnumberAmount in cents (for example 999 for $9.99). Converted to an integer natively
currencystringISO 4217 currency code (for example 'USD', 'EUR')
productIdstringYour product identifier
startDatestring?ISO 8601 date string, for example 2026-09-14T10:21:33Z. Defaults to now. iOS parses it with ISO8601DateFormatter, which rejects fractional seconds; Android falls back to now if it can't parse it

The promise resolves true once the native SDK has the purchase. It stores it and sends it when authenticated.

Tracking cancellations and refunds

typescript
// Log a cancellation
await Grovs.logCustomPurchase('cancel', 999, 'USD', 'premium_monthly');
 
// Log a refund
await Grovs.logCustomPurchase('refund', 999, 'USD', 'premium_monthly');

App Store and Google Play cancellations and refunds are detected automatically through the platform server notifications.

Last updated 2026-10-27
Was this page helpful?