> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lantern.is/llms.txt
> Use this file to discover all available pages before exploring further.

# referral_code

> Access the customer's unique referral tracking code for sharing with friends.

## Syntax

<Tabs>
  <Tab title="Liquid">
    ```liquid theme={null}
    customer.metafields.lantern.referral_code
    ```
  </Tab>
</Tabs>

## Description

The `referral_code` metafield contains the customer's unique referral tracking code used for the referral program. This code can be shared with friends and family to track successful referrals and award referral bonuses. The code is automatically generated when a customer becomes eligible for the referral program.

<Info>
  Referral codes are unique, URL-safe strings that remain constant throughout the customer's lifetime unless manually reset.
</Info>

## Properties

**Type:** `String`
**Namespace:** `lantern`

## Return Values

| Scenario                                | Value                           | Type   |
| --------------------------------------- | ------------------------------- | ------ |
| Customer has referral code              | Code string (e.g., `"JOHN123"`) | String |
| Customer eligible but no code generated | `null`                          | null   |
| Not eligible for referrals              | `null`                          | null   |
| Logged out                              | `null`                          | null   |

## Examples

### Basic Referral Code Display

```liquid theme={null}
{% assign referral_code = customer.metafields.lantern.referral_code %}
{% if referral_code %}
  <div class="referral-code-display">
    <h4>Your Referral Code</h4>
    <div class="code-container">
      <code class="referral-code">{{ referral_code }}</code>
      <button class="copy-btn" data-copy="{{ referral_code }}">Copy</button>
    </div>
    <p>Share this code with friends to earn rewards!</p>
  </div>
{% endif %}
```
