Identify a Subscriber
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.
Note: The RH.identify
function is an advanced version of the 'Add a Subscriber' 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 'Add a Subscriber' function, as 'Add a Subscriber' will also identify the subscriber.
Parameters
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.
Force (Boolean, Optional): Determines whether to override an existing session. The default value is
false
. Set this totrue
to force identification even if the user is already identified.Callback (Function, Optional): A callback function that is executed if the identification succeeds. This function receives the subscriber data as a parameter.
Important: Replace 'MFxxxxxxxxxx'
with your actual campaign UUID.
Implementation Example
Here’s how you might use the RH.identify
function with a form submission:
Detailed Behavior
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 tofalse
.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 thecallbacks.ready
method to ensure that the code runs only after ReferralHero has finished loading.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 totrue
.
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 callRH.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. Settingupsert
tofalse
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.
Last updated