Referral Rocket
HomeDashboard
  • What is Referral Rocket?
  • Referral Program Examples
  • Getting Started
    • Campaigns
      • Campaign Types
      • Campaigns Details
        • Milestone Details
        • Reward Details
        • Referrer Widget
        • Invitee Widget
      • Installing/Tracking your Referral Campaign
        • Option 1: Hosted Solution (No/Low Code)
        • Option 2: Custom Solution
          • Simple Referral Program Redirect: Quick Setup Guide
          • Redirect user to hosted campaign
          • Embed Referral Rocket Widget
          • Integrate the referral program inside your webapp for logged in user
        • Referral Tracking
          • Track referral on Sign Up page
          • Track referral on Payments
      • Reward Management
      • Campaign Participants
      • Campaign Dashboards
  • Developer Tooks
    • Javascript SDK
    • REST API
      • API Endpoint
    • Webhooks
      • Setup
      • Testing
      • Events
  • Integrations
    • Stripe
      • How to setup Stripe?
        • Stripe Settings
      • Referral Tracking with Stripe
        • Promo Code Referral Tracking with Stripe
        • Setup Stripe Pricing Table
        • Setup Stripe Payment Links
        • Setup Stripe Payment Button
        • Stripe Checkout Sessions
    • Cashfree
    • Razorpay
    • MemberSpace
    • Outseta
    • Shopify
      • How to setup Shopify?
      • Add Referral Widget on Shopify Stor
      • Popup Script to Display Discount Codes
    • ScoreApp
  • Rewards
    • Tremendous
      • How to integrate Tremendous?
        • Tremendous Settings
      • How to issue rewards with Tremendous?
    • PayPal Mass Payments
    • Wise Batch Payments
    • Stripe
    • Shopify
    • RazorPayX
    • Paypal
  • Affiliate Hub
    • Affiliate Program Hub
  • Product Updates
    • December 2024
  • Trust Center
  • Contact Us
  • FAQ
    • Where to find Campaign ID?
    • Understanding the Test Plan: Perfect for Testing, Limited for Production
Powered by GitBook
On this page
  • Getting Started
  • API Reference
  • 1. Get Campaign Detail
  • 2. Add Participant
  • 3. Get Participant Detail
  • 4. Qualify Participant
  • 5. Get Referral Code
  • 6. Validate Referrer Code
  1. Developer Tooks

Javascript SDK

Referral Rocket makes it easy to interact with your data via our Javascript SDK. This article explains the Referral Rocket JavaScript Web APIs, showing how to use each method with examples.

PreviousCampaign DashboardsNextREST API

Last updated 3 months ago

Getting Started

Install Referral Rockets library that attaches the Rocket library to the global window. Replace the campaign ID with your campaign ID. Place this script in the <head> section of your website.

// Add this script in the HEAD tag
<script type="text/javascript" campaign-id="YOUR-CAMPAIGN-ID" defer src="https://app.referralrocket.io/widget/widgetIndex.js"></script>

Verify Installation

You can confirm that the Rocket object is available by opening the browser window and enter window.Rocket. If the installation is successful, it will return an instance of the Referral rocket object.

API Reference

1. Get Campaign Detail

Retrieves the details of your campaign.

Method Signature

Retrieving Campaign Using a Promise

Example Response

2. Add Participant

The Add Participant method allows you to add a new participant—either referred or direct. A notable feature of this method is that passing a referral code or referral email is optional. The system will automatically detect the referral from the stored cookie and add it to the participant’s information.

Method Signature

Parameters

Parameter
Data Type
Description

data

Object

An Object containing the participant email and any other additional data to include for the participant.

Example Object: {

email: 'john@gmail.com', fName: 'John', lName: 'Taylor', referredByCode{optional]: 'dkghdgzd',

referredByEmail[optional]:'mike@gmail.com'

}

Referred by fields are optional. If a referral is detected via a cookie, it will be automatically associated with this participant.

Description of Object Properties

  • email: The email of the participant.

  • fName: The first name of the participant.

  • lName: The last name of the participant.

  • referredByCode [optional]: The referring customers unique code, typically used to track the referring participant. Only required for referred participants.

  • referredByEmail [optional]: The referring customers email, typically used to track the referring participant. Only required for referred participants.

Examples

Adding Participant with Object Using a Promise

Example Response

3. Get Participant Detail

Retrieves limited details of an existing participant by their email or Referral-code.

Method Signature

Parameters

Parameter

Data Type

Description

data

Object

(Required) An Object containing either the email or the referral code of the participant to retrieve.

Description of Object Properties

  • email: The email of the participant.

  • code: The referral code of the participant.

Example

Retrieving Participant Using a Promise

Example Response

4. Qualify Participant

The Qualify Participant method is used when an user makes a payment or performs a reward qualifying event (such as sign up, purchase, etc) indicating a referral has occurred and referrer is eligible for reward.

The system takes the email address of a referred participant and marks their qualifying event (sign up, purchase, etc) as complete in the campaign. This will trigger the referring participants to be eligible for a reward.

The system will automatically detect the referral from the stored cookie and add it to the participant’s information.

Method Signature

const campaign = window.Rocket.getCampaign();
campaign.qualifyParticipant({
    email: 'mike@gmail.com',
    amountPaid; 150.00,
    rewardReferee: false
});

Parameters

Parameter

Data Type

Description

data

Object

(Required) An Object containing the email of the participant. (Optional) Amount spent by the participant. (Optional) rewardReferee: Generate a reward for the referee in addition to the referrer

Description of Object Properties

  1. email

  2. amountPaid

  3. rewardReferee

{
"email": "mike@gmail.com",
"amountPaid": 150,
"rewardReferee": false
}

Example

Fulfill the reward event api using a promise.

Example Response

5. Get Referral Code

Using the getReferrralCode() function returns the referral code if available. If a referral code is not found, it will return null.

Example Usage:

6. Validate Referrer Code

Using the validateCode(code) function returns a boolean if the referral code if valid.

Example Usage:

Returns a that resolves with an containing limited campaign data.
Promise
Object