Flutter SDK

Full reference for onramp_sdk. Works with Flutter on iOS and Android.


Installation

bash
flutter pub add onramp_sdk

Milestone tracking and sessions are pure Dart (dart:io and http). Deep-link attribution (see Attribution below) pulls in the app_links plugin - no manual native setup beyond the standard platform Universal Link/App Link configuration your app already needs for deep links to work at all.


Setup

Call OnRamp.initialize() once when your app starts, before any OnRamp.step() calls. A good place is main() or your root widget's initState.

dart
import 'package:flutter/material.dart';
import 'package:onramp_sdk/onramp_sdk.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await OnRamp.initialize(
    apiKey: 'onr_YOUR_API_KEY',
    appVersion: '1.0.0', // optional - surfaces a version breakdown in your dashboard
  );
  runApp(const MyApp());
}

Your API key is on the Settings page of each app in the dashboard.

OnRamp.initialize() options

OptionTypeRequiredDefaultDescription
apiKeyStringYes-Your API key from Settings
hostStringNohttps://ingest.getonramp.devOverride the ingestion endpoint for self-hosting
appVersionString?NonullApp version string, e.g. "2.4.1" - shows in version breakdown
captureInstallReferrerboolNofalseCapture install attribution (deep links) automatically - opt-in, see Attribution below

Tracking steps

OnRamp.step(name, {properties?})

Records a funnel milestone. Safe to call from any widget or service - the SDK fires and forgets over HTTP.

dart
import 'package:onramp_sdk/onramp_sdk.dart';

// Basic
OnRamp.step('account_created');

// With custom properties
OnRamp.step('subscription_started', properties: {
  'plan': 'pro',
  'billing_period': 'annual',
  'price_usd': 79.99,
});

Options

OptionTypeDescription
propertiesMap<String, Object>?Custom key-value data attached to the event

Property values must be primitives - strings, numbers, or booleans. Nested maps are not supported. Numeric values become queryable as custom metrics in the funnel chart.


Identifying users

OnRamp.identify(traits)

Associates the current anonymous user with known identity traits. Call once after sign-in so integrations (Stripe, RevenueCat) can match the user to external records.

dart
// After the user signs in
OnRamp.identify({
  'email': user.email,
  'userId': user.id,
});

identify() is entirely optional. All funnel and retention features work without it. Only call it if you have an integration connected and want to correlate OnRamp sessions with external revenue data.


Attribution

The SDK can capture which channel or campaign drove an install, so you aren't blind to what's working the way you would be with milestone data alone. This is off by default - set captureInstallReferrer: true to turn it on:

dart
await OnRamp.initialize(apiKey: 'onr_YOUR_API_KEY', captureInstallReferrer: true);

It defaults to false rather than true because turning it on starts collecting a new category of data (campaign/referrer info) that you should consciously opt into rather than get for free on an SDK upgrade. OnRamp.setAttribution() (below) works regardless of this flag, so it's always safe to call if you get attribution data from elsewhere.

Deep links

On app launch, the SDK reads utm_source/utm_medium/utm_campaign/utm_term/utm_content from the Universal Link/App Link that opened the app (falling back to known ad click IDs - gclid, fbclid, etc). This is attached once, to the very first tracked event for the install, and never re-attached on later app opens.

myapp://open?utm_source=newsletter&utm_medium=email&utm_campaign=spring_launch

Configuring the Universal Link (iOS associatedDomains) or App Link (Android intentFilters) itself is a separate, still-required app configuration step - the SDK only reads the URL once your app is already set up to receive it.

OnRamp.setAttribution()

If you already use an MMP (Adjust, AppsFlyer, Branch, etc.) for install attribution, leave captureInstallReferrer at its default false and call this from your MMP's attribution-resolved callback instead:

dart
await OnRamp.initialize(apiKey: 'onr_YOUR_API_KEY'); // captureInstallReferrer left at its default (false)

// Inside your MMP's attribution callback:
OnRamp.setAttribution(source: 'facebook', medium: 'paid_social', campaign: 'summer_promo');

This works independently of captureInstallReferrer - it's always safe to call, whether or not you've turned on OnRamp's own capture. No-ops if attribution has already been attached to this install's first tracked event.

Play Install Referrer / Apple Search Ads coming later

Android Play Install Referrer and Apple Search Ads attribution (available in the React Native SDK and iOS SDK) aren't yet available for Flutter. setAttribution() above is the way to bring that data in today if you already have it from your own MMP. Neither Apple nor Google exposes organic App Store/Play Store search-term data, regardless of platform.

Not covered: ad-network postback attribution

SKAdNetwork (Facebook/TikTok/etc install attribution) and deferred deep linking (matching a pre-install ad click to an install after a detour through the App/Play Store) aren't built into OnRamp - that's full MMP territory (Adjust/AppsFlyer/Branch). If you already have one of those for this, OnRamp.setAttribution() above is the way to bring its resolved data into your OnRamp funnels.


Session management

OnRamp.newSession()

Force-starts a new session. Call after sign-out so the next user starts fresh.

dart
Future<void> handleLogout() async {
  await signOut();
  OnRamp.newSession();
}

OnRamp.flush()

Waits for all in-flight events to finish sending. Useful before the app is suspended or when running integration tests.

dart
@override
void dispose() {
  OnRamp.flush();
  super.dispose();
}

Server-side correlation

OnRamp.getIds()

Returns the current anonymous and session IDs so your backend can associate server-side events (purchases, trial starts) with this session.

dart
final ids = OnRamp.getIds();
await myApi.post('/checkout', {
  'onramp_anonymous_id': ids.anonymousId,
  'onramp_session_id': ids.sessionId,
});

Platform support

The SDK reports platform automatically based on dart:io:

PlatformReported as
iOSios
Androidandroid
macOSmacos
Otherother

Offline support

Events are sent immediately over HTTP. If the network is unavailable, the call fails silently. For guaranteed delivery in poor network conditions, call OnRamp.flush() at lifecycle boundaries (e.g. AppLifecycleState.paused) to ensure in-flight events complete before the OS suspends the app.