Revenue
Track in-app purchases and custom payments with the Grovs Flutter SDK
Revenue tracking lets you attribute purchases to links and campaigns, monitor metrics like ARPU and LTV, and view breakdowns by product and platform, all from the Grovs dashboard.
Revenue tracking is currently in beta.
On self-hosted deployments, revenue tracking is part of the Enterprise edition (GROVS_EE=true). On a Community edition backend the purchase endpoint does not exist.
Setup
1. Enable revenue tracking in the dashboard
- Open the Grovs dashboard
- Go to your project's Settings
- Under Revenue Tracking, click Enable
2. Configure platform notifications
- Android: set up Google Play Real-Time Developer Notifications. See the Android Revenue guide for the full walkthrough.
- iOS: configure App Store Server Notifications in App Store Connect. See the iOS Revenue guide.
Logging purchases
Platform store purchases
For purchases made through the App Store or Google Play, pass the platform-specific transaction identifier as a string. The plugin routes it to the native SDK for the platform the app is running on:
import 'dart:io' show Platform;
import 'package:grovs_flutter_plugin/grovs.dart';
final grovs = Grovs();
if (Platform.isIOS) {
// The StoreKit 2 transaction ID, as a decimal string
await grovs.logInAppPurchase(transaction.id.toString());
} else {
// The Play Billing purchase's originalJson
await grovs.logInAppPurchase(purchase.originalJson);
}On iOS the string must parse as an unsigned 64-bit integer; anything else fails with a GrovsException whose code is INVALID_ARGUMENT. If the native SDK reports that it could not log the purchase, the code is PAYMENT_ERROR. On Android the string is handed to the native SDK as-is, and a GrovsException with PAYMENT_ERROR is thrown only if the native call throws.
What happens next is native behavior: the backend looks the transaction up, fills in product, price, and currency, and de-duplicates repeated calls. See iOS Revenue and Android Revenue.
Custom purchases
For purchases processed through Stripe, PayPal, or any non-store payment system:
import 'package:grovs_flutter_plugin/models/grovs_link.dart';
await grovs.logCustomPurchase(
type: TransactionType.buy,
priceInCents: 999, // $9.99
currency: 'USD',
productId: 'premium_monthly',
);Parameters:
| Parameter | Type | Description |
|---|---|---|
type | TransactionType | buy, cancel, or refund |
priceInCents | int | Amount in cents (e.g. 999 for $9.99) |
currency | String | ISO 4217 currency code (e.g. 'USD', 'EUR') |
productId | String | Your product identifier |
startDate | DateTime? | Transaction date. Sent as milliseconds since the epoch and honored on both platforms as of plugin 3.0.0. When omitted the native SDK uses the current time |
Tracking cancellations and refunds
// Log a cancellation
await grovs.logCustomPurchase(
type: TransactionType.cancel,
priceInCents: 999,
currency: 'USD',
productId: 'premium_monthly',
);
// Log a refund
await grovs.logCustomPurchase(
type: TransactionType.refund,
priceInCents: 999,
currency: 'USD',
productId: 'premium_monthly',
);For App Store and Google Play purchases, cancellations and refunds are detected automatically when you configure platform server notifications.
While the SDK is disabled
Purchases are not sent while the SDK is disabled with setSDK(false). What the native SDKs hold and what they drop is described in Privacy & Consent.