Quickstart

Get AppRefer running in your app in under 5 minutes. This guide covers installation, initialization, and verification for both Flutter and iOS.

Prerequisites#

  • An AppRefer account with at least one app created
  • A Flutter or native iOS app
  • RevenueCat for subscription tracking (optional but recommended)

Step 1: Create an App#

In the AppRefer dashboard, go to Settings and create a new app. You will receive two SDK keys:

  • pk_live_... — for production builds
  • pk_test_... — for development and testing

Step 2: Install the SDK#

Add the AppRefer Flutter SDK to your pubspec.yaml:

pubspec.yaml
dependencies:
  apprefer_flutter_sdk:
    git:
      url: https://github.com/AppAgentic/apprefer-flutter-sdk.git
      ref: main

Then install:

flutter pub get

Step 3: Initialize the SDK#

Call configure() as early as possible in your app's lifecycle — ideally at startup. This resolves attribution by matching the device to a tracked click.

main.dart
import 'package:apprefer_flutter_sdk/apprefer_flutter_sdk.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final attribution = await AppReferSDK.configure(AppReferConfig(
    apiKey: 'pk_live_your_key_here',
  ));

  if (attribution != null) {
    print('Attributed to: ${attribution.network}');
    print('Match type: ${attribution.matchType}');
  }

  runApp(const MyApp());
}

Live vs Test keys

The server derives the environment from the key prefix. pk_live_ keys route to production. pk_test_ keys route to sandbox — events are logged for debugging but never forwarded to ad networks.

Step 4: Link AppRefer to RevenueCat#

CRITICAL — Required for purchase attribution

You must set the appreferId attribute on RevenueCat immediately after calling configure(). This is how RevenueCat webhooks are matched back to AppRefer attributions. Without this, purchase events cannot be attributed.
final attribution = await AppReferSDK.configure(AppReferConfig(
  apiKey: 'pk_live_your_key_here',
));

// REQUIRED: Link AppRefer to RevenueCat for purchase attribution
await Purchases.shared.setAttributes({"appreferId": attribution.deviceId});

// Optional: Set your app's user ID for additional matching
AppReferSDK.setUserId(currentUser.userId!);

Step 5: Create Tracking Links#

In the dashboard, go to Links and create a tracking link for each ad campaign. Configure the network, campaign name, ad set, and ad creative. Use the generated link as your ad destination URL — it will capture click IDs and redirect to the App Store or Play Store.

Step 6: Connect Ad Networks#

Go to Settings → Integrations and configure each ad network you want to forward conversions to. You will need:

  • Meta: Pixel ID and Conversions API access token
  • Google Ads: Customer ID, Conversion Action ID, and OAuth credentials
  • TikTok: Pixel Code and access token

Step 7: Verify with Debugger#

Open the Debugger tab in the dashboard. It polls for SDK events in real-time. Run your app, and you should see the configure event appear within a few seconds. Check that attribution was resolved correctly by inspecting the event details.

Sandbox testing

Use pk_test_ during development. Test events appear in the Debugger sandbox view and are never forwarded to ad networks. Switch to pk_live_ only when you are ready to go live.