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
  • Parameters
  • Implementation Example
  • Detailed Behavior
  • ReCaptcha

Was this helpful?

  1. Integrate
  2. Javascript Web API

Identify a Subscriber

PreviousTrack TransactionNextIdentify a Referrer

Last updated 2 months ago

Was this helpful?

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>

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