# Add a Pending Referral

```javascript
RH.pendingReferral(uniqueIdentifier);
```

This function is used to track referrals that enter the first step of a multi-step conversion event .

{% hint style="warning" %}
**GOAL: Two or Three Conversion Events**

Your campaign Goal must be set up to track two or three conversion events, only then the following tracking logic will take place:

* **Tracking Referrals:**
  * When a user is referred to your campaign, they enter the first step of your multi-step conversion event.
  * At this point, a referral will be automatically created and marked as "Pending" within the appropriate campaign. This status indicates that the referral has begun the conversion process but hasn't yet completed all the necessary steps.
* **Non-Referrals:**
  * If the user is not a referral (i.e., they weren't referred by someone else in your campaign), no action is taken. Specifically, no subscriber record will be created for them.
  * This ensures that only those users who are actually referred are tracked within the multi-step process.
{% endhint %}

**Implementation Example**

To add a pending referral, simply call ReferralHero's `RH.pendingReferral()` function, passing in user information such as an email address, name, or any other identifier set up for your campaign.&#x20;

Here is an example of how to implement this:

{% tabs %}
{% tab title="Javascript" %}
```javascript
<script type="text/javascript">
  window.RHConfig = {
    callbacks: {
      ready: function() {
        var form = document.getElementById('referral-form');
        
        form.addEventListener('submit', function(e) {

          // Collect form data
          var data = {
            name: form.querySelector('#name').value,
            email: form.querySelector('#email').value
          };

          // Call pendingReferral function with collected data
            RH.pendingReferral(data);
        });
      }
    }
  };
</script>
```
{% endtab %}

{% tab title="Web form" %}
```erb
<h2>Track Pending Referral</h2>
<form id="referral-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 Referral</button>
</form>
```
{% endtab %}
{% endtabs %}

{% hint style="danger" %}
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 Dashboard, 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.
{% endhint %}

#### Check if a Pending Referral is Tracked or not

1. **Open the Console:**
   * Before submitting the form, open your browser's Developer Tools and go to the **Console** tab.
2. **Submit the Form:**
   * Fill in the form fields (e.g., name and email) and click "Submit."
3. **Check the Console:**

<figure><img src="https://1427773792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhQxsg0xCpG1doJ626L8X%2Fuploads%2FBKhLmiC7pjF2QCKZSGv9%2FUntitled%20design.png?alt=media&#x26;token=43b02503-b7a4-4f01-ad7a-14e535c41166" alt=""><figcaption><p>Pending Referral is successfully tracked (Referred by someone)</p></figcaption></figure>

<figure><img src="https://1427773792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhQxsg0xCpG1doJ626L8X%2Fuploads%2FfGhV1MeShVNs3XHojg0c%2FScreenshot%202024-08-27%20at%203.58.52%E2%80%AFPM.png?alt=media&#x26;token=c3bee97d-5221-4d8b-ba82-6fc8e4d65a69" alt=""><figcaption><p>Pending Referral is not tracked ( Not referred by anyone )</p></figcaption></figure>

* After confirming in the console that the pending referral is tracked, you can then verify that the referral appears as "Pending" in your ReferralHero dashboard.

<figure><img src="https://1427773792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhQxsg0xCpG1doJ626L8X%2Fuploads%2FZPNz1H6BtX2bE0zqY5wH%2FScreenshot%202024-08-27%20at%203.40.27%E2%80%AFPM.png?alt=media&#x26;token=6fb071f3-32c8-493b-8eaf-6a75d753635e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1427773792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhQxsg0xCpG1doJ626L8X%2Fuploads%2FBqsGLcCWlKfwNv9AjwD3%2FScreenshot%202024-08-27%20at%203.40.38%E2%80%AFPM.png?alt=media&#x26;token=f10f8bf5-c077-4636-a54b-0ef60289451d" alt=""><figcaption></figcaption></figure>
