Lantern
Liquid API

referral_code

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

Syntax

customer.metafields.lantern.referral_code

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.

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

Properties

Type: String Namespace: lantern

Return Values

ScenarioValueType
Customer has referral codeCode string (e.g., "JOHN123")String
Customer eligible but no code generatednullnull
Not eligible for referralsnullnull
Logged outnullnull

Examples

Basic Referral Code Display

{% 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 %}