Revenue
Track in-app purchases and custom payments with the Grovs Flutter 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.
Self-hosted: revenue tracking needs the Enterprise edition (GROVS_EE=true). A Community edition backend has no purchase endpoint.
Setup
1. Enable revenue tracking in the dashboard
- In the Grovs dashboard, go to Analytics → Revenue.
- 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
- Android: set up Google Play Real-Time Developer Notifications. See the Android Revenue guide.
- iOS: configure App Store Server Notifications in App Store Connect. See the iOS Revenue guide.
Logging purchases
Platform store purchases
Pass the platform's transaction identifier as a string. The plugin routes it to the current platform's native SDK:
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);
}- iOS: the string must parse as an unsigned 64-bit integer, or a
GrovsExceptionwith codeINVALID_ARGUMENTis thrown. If the native SDK can't log the purchase, the code isPAYMENT_ERROR. - Android: the string goes to the native SDK as-is.
PAYMENT_ERRORis thrown only if the native call throws.
The backend then 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 through Stripe, PayPal or any non-store 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 (for example 999 for $9.99) |
currency | String | ISO 4217 currency code (for example 'USD', 'EUR') |
productId | String | Your product identifier |
startDate | DateTime? | Transaction date, sent as milliseconds since the epoch. Honored on both platforms since plugin 3.0.0. Defaults to now |
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',
);App Store and Google Play cancellations and refunds are detected automatically through the platform server notifications.
While the SDK is disabled
Purchases aren't sent while disabled with setSDK(false). What the native SDKs hold or drop: Privacy & Consent.