Links

Track custom referral events

ReferralHero allows you to track custom events as referrals so that you can reward people who refer friends who complete a specific action, e.g: creates an account on your website, makes a purchase, schedules a call, etc. If you're trying to set this up on Shopify, please see here.
NOTE
Tracking a custom referral event will only work for campaigns that are configured to accept referrals as custom events. To do that, go to your campaign dashboard > Edit campaign > Goal and choose "Track multi-step conversion events".
Example of a multi-step conversion event:
A tax agency incentives customers who refer people to book a consultation who later purchase their product.
  1. 1.
    Referral books an appointment, referral status marked as ‘Pending’
  2. 2.
    Referral completes a purchase, referral status marked as ‘Confirmed’

Add a Pending Referral

To add a pending referral, simply call ReferralHero's RH.pendingReferral() function and send the user information such as email address and name.
RH.pendingReferral(uniqueIdentifier);
<script>
window.RHConfig = {
callbacks: {
ready: function() {
var data = {
name: 'Dev Test',
};
if (RH) {
RH.pendingReferral(data);
}
}
}
}
</script>
IMPORTANT
  • '#email, '#phone_number', '#crypto_wallet_address' or '#other ID' that have been enabled as the campaign unique identifier is required and can’t be blank.
  • The ReferralHero Combo, Signup, Floating Widget, or Javascript API can only be used once on a single webpage. Do not add them multiple times on the same webpage.
  • If you are using the ReferralHero Blockchain integration you must also send the '#crypto_wallet_provider' in the following format: metamask phantom coinbase ledger exodus trezor myetherwallet jaxx guarda trustwallet

Track Referral Conversion Event

To track a conversion, simply call the following Javascript code:
RH.trackReferral(uniqueIdentifier);
NOTE:
  • uniqueIdentifier is a placeholder.
  • When tracking referrals on your website you should ALWAYS send the ACTUAL unique identifier (email, phone number, crypto wallet address, or other ID) of the referral.
  • If you don't have the user’s unique identifier, read below for alternative options.
uniqueIdentifier is the Unique Identifier of the person who has converted and it's required.
You should call trackReferral() when the conversion happens. For example, if you want to trigger a referral when they upgrade to a paid plan, then this is how you could do it:
<script>
var purchase = function(uniqueIdentifier) {
if (RH) {
RH.trackReferral(uniqueIdentifier);
}
}
</script>
However, if you want to trigger a referral on page load (for example when they visit a "Thank you page" after they convert), it's better to call trackReferral() inside the ready() callback to make sure the ReferralHero object has already been loaded, like this:
<script type="text/javascript">
window.RHConfig = {
callbacks: {
ready: function() {
RH.trackReferral(uniqueIdentifier);
}
}
}
</script>
IMPORTANT
Make sure the ReferralHero Tracking Code is installed on the page where you trigger the referral. Also, the above example code must be called BEFORE the ReferralHero Tracking Code.

Track Referral Conversion or Add Subscriber

RH.trackReferral() is used when you would like to confirm referrals only on the conversion page. If you would like to track referrals or add organic subscribers on the conversion page to your referral campaign, you can use the following script:
RH.organicTrackReferral(uniqueIdentifier);
1. If referral, cookied or in the ReferralHero database, add and confirm the referral.
or
2. Add an organic subscriber if the subscriber does not exist in the ReferralHero database.
<script type="text/javascript">// <![CDATA[
window.RHConfig = {
callbacks: {
ready: function() {
var data = {
name: "new user"
}
RH.organicTrackReferral(data)
}
}
}
// ]]
</script>
Example:
  1. 1.
    A referred referral signs up for your campaign on your lead magnet page and is marked as a Pending Referral.
  2. 2.
    Referral later completes a purchase.
  3. 3.
    RH.organicTrackReferral() confirms the referral by changing the Referral Status from Pending to Confirmed.
  4. 4.
    An organic customer (not referred) completes a purchase.
  5. 5.
    RH.organicTrackReferral() adds the customer as an organic subscriber to your campaign (so they can start referring).

Sending extra data

You can add an optional second parameter to send extra data about the referral, like the name or the value of the conversion.
var data = {
name: 'John Doe',
value: 54.3,
transaction_id: 'AJGJY87782h8h',
category: 'upgrade'
}
RH.trackReferral(uniqueIdentifier, data);
The extra data you can send are:
  • name The subscriber's name
  • value The monetary value of the referral. E.g if the referral is worth $52, send 52
  • transaction_id The unique ID of the transaction. This is useful if you're tracking purchases and want to be able to associate a referral to a specific transaction later.
  • category The type of referral. Useful if you're tracking conversion in several places or for different products and want to be able to create reports.

Tracking referrals without emails

Whilst ReferralHero requires the unique identifier of the referral to trigger the conversion, the identifier doesn’t need to be real. If you don’t care about the identity of the referral, or simply don’t have their identifier info, you can use a random one. Just make sure the random identifier you pass over is unique.
Here's an example code of how to generate unique email addresses:
var random_email = Math.random().toString(36).substring(2) + "@email.com" // Create an email address like [email protected]
RH.trackReferral(random_email);

Callback

Optionally, you can execute a function after the referral has been tracked. You can do so by adding a third argument to the trackReferral() function, like this:
<script>
var getReferralLink = function(data) {
// Your custom logic
}
RH.trackReferral(uniqueIdentifier, data, getReferralLink(data));
</script>
If you don't want to send extra data, you can pass on the callback function as the second parameter, like this:
<script>
var getReferralLink = function(data) {
// Your custom logic
}
RH.trackReferral(uniqueIdentifier, getReferralLink(data));
</script>