> For the complete documentation index, see [llms.txt](https://support.referralhero.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.referralhero.com/integrate/mobile-sdks/flutter-sdk/getting-started.md).

# Getting Started

### Getting started

To start using the ReferralHero SDK, you will need to add it to your project as a package from pub.dev.

#### Adding the Dependency

**Step 1:**

1. Open your Flutter project.
2. Add the following dependency to your `pubspec.yaml` file:

```yaml
dependencies:
  referral_hero_flutter: latest_version
```

3. Run `flutter pub get` to fetch the new dependency.

**Step 2:**

1. Import ReferralHero in your Dart code:

```dart
import 'package:referral_hero/referral_hero.dart';
```

2. Initialize the SDK in your main application file (`main.dart`):

```dart
late ReferralHeroFlutter _referralHeroService;

  final apiKey = "Your-api-key";
  final uuid = "You-uuid";

  @override
  void initState() {
    super.initState();
    _referralHeroService = ReferralHeroFlutter(apiKey, uuid);
  }
```

**Step 3:**

1. Get your `API_TOKEN` from the ReferralHero Dashboard -> API: [ReferralHero Dashboard](https://app.referralhero.com/dashboard/apis).

<figure><img src="/files/q03HYKNixfCNm3kVZhXU" alt=""><figcaption></figcaption></figure>

2. Back in the ReferralHero overview, click to edit your desired Campaign.

<figure><img src="/files/t0Xk41jVWZkQ1jEMOb9Z" alt=""><figcaption></figcaption></figure>

3. Then the Installation tab, then Mobile App Installation.

<figure><img src="/files/aDknlH2tdQAUp1bprw8n" alt=""><figcaption></figcaption></figure>

4. Get your `UUID`: The 12-letter ID that starts with ‘MF’ in *Edit Campaign > launch > Mobile app installation*, e.g. MF15298bba6d.

<figure><img src="/files/gIShBRDsUkvAPaB1fCso" alt=""><figcaption></figcaption></figure>

5. Add the Campaign Token obtained from the campaign, and UUID from the installation Tab.

**Step 4:**

In the Goal section of your Campaign settings, ensure you have added the Google Play and Apple App Store links and a default referral link for desktop web users.

<figure><img src="/files/N21aOjiKpDmkEkMy2M7V" alt=""><figcaption></figcaption></figure>

Well done! You should now be able to build and run your campaign. Before using the more advanced features of the SDK, you should learn about a couple of important concepts.

## Tracking Referrals

Now that you have implemented the SDK, you can start identifying and tracking referrals!

For that, you will need 2 things:

1. Universal Link
2. Your Integrated App

The RH SDK Pulls information from your Device, like this:

```dart
final referralParams = {
  'email': 'user@example.com', // Capture this from user
  'domain': 'https://a.domain.co/', // Optional value, and set as default by admin
  'name': 'User Name', // Capture this from user
  'referrer': 'referrerCode', // Optional value, only necessary if you want to capture the referrer code from user
  'uuid': 'MFxxxxxxxxx', // Get this from RH Dashboard
  'device': referralHeroService.deviceInfo.getDeviceType(), // Get device type
  'ip_address': referralHeroService.deviceInfo.getIpAddress(), // Get IP address
  'os_type': referralHeroService.deviceInfo.getOperatingSystem(), // Get operating system type
  'screen_size': referralHeroService.deviceInfo.getDeviceScreenSize() // Get screen size
  'status': 'custom_event_pending' // Use 'custom_event_pending' to set the referral status to pending
};
```

The format for screen sizes is not native to RH, and the format should be parsed to RH accepted, such as:

```dart
String transformResolution(String input) {
  final dimensions = input.split('*').map((e) => e.trim()).toList();
  return '${dimensions[0]} x ${dimensions[1]}';
}
```

With this information, you should be able to add the subscriber data, with the Get Referrer, Add Subscriber, Create Pending Referral, or Track Referral methods to automatically identify or track a referral:

```dart
void formSubmit() {
  referralHeroService.addSubscriber(referralParams);
}
```

To further understand the implementation of these methods, please check the Public Methods section, and our Github Sample Project.
