# 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.

Here is an example of how to implement this:

{% tabs %}
{% tab title="JavaScript" %}

```html
<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,
            tags: ["tag1", "tag2"] // Optional ( assign tags to subscriber )
          };

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

{% endtab %}

{% tab title="Web Form" %}

```html
<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="/files/GbsVF04gJtLZrdibJlFB" alt=""><figcaption><p>Pending Referral is successfully tracked (Referred by someone)</p></figcaption></figure>

<figure><img src="/files/mD6b8mdM5hlkggeEioIr" alt=""><figcaption><p>Pending Referral is successfully tracked (Referred by someone)</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="/files/hLGSNTqb31z4KsxulKAq" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.referralhero.com/integrate/javascript-web-api/track-custom-referral-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
