Track multi-step conversion events

ReferralHero allows you to track multi-step conversion events as referrals go through your conversion funnel so that you can reward people who refer friends and complete a specific action, e.g. sign up and purchase, book a call and purchase, create an account and subscribe, etc. If you're trying to set this up on Shopify, please see here.

NOTE

Tracking a multi-step conversion event will only work for campaigns that are configured to track referrals through multi-step events. To do that, go to your campaign dashboard > Edit campaign > Goal and choose "Track two or three conversion events".

Example of a multi-step conversion event:

A SaaS company incentivizes customers who refer people to book a demo and later purchase their product.

  1. Referral books an appointment, referral status marked as ‘Pending’ (tracked by 'adding a subscriber')

  2. Referral completes a purchase, referral status marked as ‘Unconfirmed/Confirmed’ (tracked by following the steps below)

Track Referral Conversion Event

To track a conversion, simply call the following Javascript code:

RH.trackReferral(uniqueIdentifier);

uniqueIdentifier is the Unique Identifier of the person who has converted and it's required.

Tracking Logic:

  • If a referral and pre-existing in the campaign as Pending

OR

  • If a referral and cookied, a referral is automatically created in the correct campaign and

The Referral Is Set To:

  • Confirmed (if tracking two conversion events)

  • Unconfirmed (if tracking three conversion events)

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>

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.

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

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_MFxxxxxxxxxx.organicTrackReferral(uniqueIdentifier);

Tracking Logic:

  • If a referral and pre-existing in the campaign as Pending

OR

  • If a referral and cookied, a referral is automatically created in the correct campaign and

The Referral Is Set To:

  • Confirmed (if tracking two conversion events)

  • Unconfirmed (if tracking three conversion events)

OR

  • If not a referral, an organic subscriber is created in the campaign UUID specified.

<script type="text/javascript">// <![CDATA[
    window.RHConfig = {
        callbacks: {
            ready: function() {
            
                var data = {
                    email: "new_user@test.com",
                    name: "new user"
                }
                RH_MFxxxxxxxxxx.organicTrackReferral(data)
            }
        }
    }
// ]]
</script>

IMPORTANT:

'MFxxxxxxxxxx' must be replaced with your campaign UUID.

Example:

  1. A referred referral signs up for your campaign on your lead magnet page and is marked as a Pending Referral.

  2. Referral later completes a purchase.

  3. RH_MFxxxxxxxxxx.organicTrackReferral() confirms the referral by changing the Referral Status from Pending to Confirmed.

  4. An organic customer (not referred) completes a purchase.

  5. RH_MFxxxxxxxxxx.organicTrackReferral() adds the customer as an organic subscriber to your campaign defined by the UUID (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 dh83yhjdh83@email.com
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>

Last updated