ReferralHero
  • Welcome to the Support Center
  • Common Questions
  • Features
    • Subscribers
      • Subscriber Profile
      • Unique Identifier
      • Active Visitors
      • 'Quick Add' Referral
      • Update Referral Status
    • Campaign Templates
      • Contest
      • Website Referral Analysis
      • Net Promoter Score
    • Unique Identifier
      • Phone Number
      • Confirmation Email
        • Thank-You Page
    • Automations
      • A/B Test
    • Security
      • Manual Review & Confirmation
      • Secondary Verification Method
      • High Risk
      • Blacklist
      • ReCaptcha
    • Reward
      • Reward Status
      • Advanced Reward Options
      • Transactions
    • Analytics
      • Active Visitors
      • Subscribers
      • Sources
      • Shares
      • Devices
      • Unsubscribers
    • Misc
      • Memorable referral links
      • 1-Click Signup
      • Forward & Refer
      • Coupon Codes
      • Custom Attribution
  • Integrate
    • Embeddable Widgets
      • Custom Domain
    • Integrations
      • Active Campaign
      • Aweber
      • Blockchain
      • Facebook Pixel
      • Calendly
      • Discord
      • HubSpot
      • Intercom
      • KakaoTalk
      • Klaviyo
      • Mailchimp
      • Salesforce
      • SendLane
      • Slack
      • Stripe
      • Tango Card
      • Telegram
      • Tremendous
      • Twilio
      • Typeform
      • Webhooks
      • Zapier
      • Zoho
    • Platform-specific Instructions
      • Google Tag Manager
      • WordPress
      • Webflow
      • SquareSpace
      • ClickFunnels
      • Unbounce
      • Instapage
      • Shopify
      • Carrd
      • WIX
    • Javascript Web API
      • Getting Started
      • Configuration file
      • Callbacks
      • Add a subscriber
      • Add a Pending Referral
      • Track multi-step conversion events
      • Track Transaction
      • Identify a Subscriber
      • Identify a Referrer
      • Generate Dashboard Widget
      • Generate Sharing-Screen
    • ReactJS
    • REST API
      • Errors
      • Webhooks
      • Objects
      • Endpoint Reference
    • Mobile SDKs
      • iOS SDK
        • Getting Started
        • Public Methods
        • Public Classes
        • API Interaction Methods
      • Android SDK
        • Getting Started
        • Public Methods
        • Public Classes
        • Listeners & Interfaces
      • Flutter SDK
        • Getting Started
        • Public Methods
      • React Native
        • Getting Started
        • Public Methods
        • Mobile App Testing in Development Mode
      • Mobile App Testing in Development Mode
  • API Tutorials
Powered by GitBook
On this page
  • Getting started
  • Tracking Referrals

Was this helpful?

  1. Integrate
  2. Mobile SDKs
  3. Flutter SDK

Getting Started

ReferralHero Flutter/Dart SDK

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:

dependencies:
  referral_hero_flutter: latest_version
  1. Run flutter pub get to fetch the new dependency.

Step 2:

  1. Import ReferralHero in your Dart code:

import 'package:referral_hero/referral_hero.dart';
  1. Initialize the SDK in your main application file (main.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. Back in the ReferralHero overview, click to edit your desired Campaign.

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

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

  1. 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.

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:

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:

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:

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

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

PreviousFlutter SDKNextPublic Methods

Last updated 3 months ago

Was this helpful?

Get your API_TOKEN from the ReferralHero Dashboard -> API: .

ReferralHero Dashboard