Referral Hero Documentation
Getting StartedFeaturesIntegration
  • Introduction to ReferralHero
  • Getting Started
    • Quickstart
    • Creating a New Campaign
      • Choose a Campaign Type
      • Set Your Goals
      • Define a Unique Identifier
      • Set Up Integrations
      • Set Up Automations
      • Configure Options
  • Features
    • Subscribers
      • Types Of Subscribers
  • Integrations
    • Overview
    • Embeddable Widgets
      • Advocate Dashboard Widget
      • Referral Signup Widget
      • Referral Welcome Banner
      • Sharing Widget
      • Floating Button
      • Customize the Widgets
    • 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
    • React JS
    • Platform Specific Integration
      • Shopify
      • Webflow
      • WordPress
    • Mobile SDK's
      • React Native
        • Getting Started
        • Mobile App Testing in Development Mode
    • REST API
      • Lists
        • 🟠POST lists
        • 🟢GET lists
        • 🟢GET lists/:uuid/leaderboard
        • 🟢GET lists/:uuid/bonuses
    • API Tutorials
Powered by GitBook
On this page
  • Parameters
  • Implementation Example
  • Detailed Behavior
  • ReCaptcha
  1. Integrations
  2. Javascript Web API

Identify a Subscriber

PreviousTrack TransactionNextIdentify a Referrer

Last updated 8 months ago

The RH.identify function is used to identify a subscriber so that they don’t need to manually enter their information again, such as their email address or name. This function is particularly useful for displaying embeddable widgets on internal pages of your website where you already have the subscriber’s unique identifier.

RH_MFxxxxxxxxxx.identify(data, force, callback);

Note: The RH.identify function is an advanced version of the '' function and offers additional properties like upsert, force identification, and more. It is not always necessary to call RH.identify if you have already used an '' function, as 'Add a Subscriber' will also identify the subscriber.

Parameters

  1. Data (Object, Required): An object containing user data. At a minimum, this object must include the unique identifier of the user. Additional fields can be included as needed.

  2. Force (Boolean, Optional): Determines whether to override an existing session. The default value is false. Set this to true to force identification even if the user is already identified.

  3. Callback (Function, Optional): A callback function that is executed if the identification succeeds. This function receives the subscriber data as a parameter.

var myFunc = function(data) {
   console.log(data);
}

var data = {
  email: "john@smith.com",
  name: "John Smith",
  extra_field: "USA",
  extra_field_2: null,
  upsert: true
}

RH_MFxxxxxxxxxx.identify(data, false, myFunc);

Important: Replace 'MFxxxxxxxxxx' with your actual campaign UUID.

Implementation Example

Here’s how you might use the RH.identify function with a form submission:

 <script type="text/javascript">
    window.RHConfig = {
      callbacks: {
        ready: function() {
          var form = document.getElementById('form');
            form.addEventListener("submit", function(e){

              var data = {
                email: form.querySelector('#email').value,
                name: form.querySelector('#name').value,
                upsert : true
              };
              
              var myCallback = function(responseData) {
                console.log("Identification successful:", responseData);
              };

              if (RH_MFxxxxxxxxxx) {
                RH_MFxxxxxxxxxx.identify(data, false, myCallback);
              }
            });
          }
        }
      };

</script>
<form id="form">
        <label for="name">Name:</label>
        <input type="text" id="name" name="name" required>

        <label for="email">Email:</label>
        <input type="email" id="email" name="email" required>

        <button type="submit">Submit</button>
    </form>

Detailed Behavior

  1. Automatic Subscriber Creation: When the RH.identify function is called, ReferralHero will check if a subscriber with that specific unique identifier exists.

    • If a subscriber is not found, a new subscriber is automatically created using the data sent over, bypassing the verification method.

    • If the subscriber with that unique identifier already exists, ReferralHero simply returns the existing subscriber data.

    If you don’t want to automatically create a new subscriber when one isn't found (e.g., to allow manual opt-in), set the upsert property to false.

  2. Load Callback: The ReferralHero Tracking Code loads asynchronously. If you intend to execute any RH functions on page load, you must wait until the library has completely loaded. Use the callbacks.ready method to ensure that the code runs only after ReferralHero has finished loading.

  3. Force Identification: By default, if a cookie session is already present (e.g., the user has already been identified in the past), ReferralHero will not attempt to identify the user again to improve the user experience. This avoids unnecessary delays (typically around 1 second).

    If you want to identify users every time regardless of an existing session, set the force parameter to true.

Note: Our recommendation is to not force identification, as it can degrade the user experience. If you force identification, ReferralHero will check the existence of the subscriber every time a person visits that page, which can slow down your website.

Important

  • If you have already called the RH.form.submit() function on a portal signup/login form, there is no need to call RH.identify() again on an internal page as the subscriber is already identified.

  • The upsert property allows you to update an existing subscriber's information or create a new subscriber if one does not exist. Setting upsert to false prevents the automatic creation of a new subscriber.

  • The force parameter can be used to override an existing session and re-identify the user if needed. However, avoid using it to prevent impacting user experience.

  • The callback parameter allows you to execute custom code upon successful identification, making it easier to handle responses or perform additional actions.

ReCaptcha

Unfortunately, if you're using ReCaptcha, RH_MFxxxxxxxxxx.identify() will not work.

Add a Subscriber
Add a Subscriber