Lantern

Accessing Lantern Data

Learn how to access Lantern data through metafields and metaobjects

Lantern continuously stores and updates all of the data it collects in Shopify as Custom Data using metafields and metaobjects. We use this data to build all of our storefront extensions so your store loads as quickly as possible. If you want to build custom experiences using Liquid, you can reference them the same way.

Learn more about accessing metafields in your Liquid code on Shopify.

For comprehensive guides and code examples, see our Liquid API documentation.

Available Customer Metafields

All metafields use the lantern.customer namespace unless noted otherwise and are automatically updated by Lantern:

Customer Profile

FieldDescriptionExample
activity_feedRecent customer activity eventsLoyalty actions, purchases, referrals
birth_dateCustomer's birthday. On facts instead of lantern"1989-12-13"
is_testerTest account flagHide from analytics, enable debug features
propertiesCustom customer properties{"favorite_category": "electronics"}
walletAll available rewards & creditsActive discounts, gift cards, product rewards, store credit balances
wishlistCustomer's wishlist itemsArray of product variant GIDs

Loyalty Program

FieldDescriptionExample Value
loyalty_tierCurrent tier name"Gold"
loyalty_pointsAvailable points balance1250
loyalty_spendCurrent period spend249.99
is_eligibleCan participate in loyaltytrue
is_blockedBlocked from rewardsfalse

Referral Program

FieldDescriptionExample Value
referral_codeUnique referral code"6b577dd5288"
is_advocateHas referred otherstrue
is_referredJoined through referraltrue

Quick Start Examples

Show Loyalty Status

{% assign points = customer.metafields.lantern.loyalty_points %}
{% assign tier = customer.metafields.lantern.loyalty_tier %}

{% if points and tier %}
  <div class="loyalty-status">
    <h3>Welcome {{ tier }} Member!</h3>
    <p>You have <strong>{{ points }} points</strong> available</p>
  </div>
{% endif %}

Display Referral Code

{% assign ref_code = customer.metafields.lantern.referral_code %}

{% if ref_code %}
  <div class="referral-share">
    <p>Share your code: <code>{{ ref_code }}</code></p>
    <p>Friends get rewards, you get rewards!</p>
  </div>
{% endif %}

Show Available Rewards Count

{% assign wallet = customer.metafields.lantern.wallet | parse_json %}

{% if wallet.items.size > 0 %}
  <div class="rewards-available">
    <p>You have <strong>{{ wallet.items.size }} rewards</strong> ready to use!</p>
    <a href="/account/rewards">View My Rewards</a>
  </div>
{% endif %}

Check Store Credit Balance

{% assign wallet = customer.metafields.lantern.wallet | parse_json %}

{% if wallet.storeCreditAccounts.size > 0 %}
  {% assign total_credit = 0 %}
  {% for account in wallet.storeCreditAccounts %}
    {% assign credit = account.balance.amount | plus: 0 %}
    {% assign total_credit = total_credit | plus: credit %}
  {% endfor %}

  <div class="store-credit">
    <p>Store Credit: <strong>${{ total_credit }}</strong></p>
  </div>
{% endif %}

Display Wishlist Count

{% assign wishlist = customer.metafields.lantern.wishlist | parse_json %}

{% if wishlist.size > 0 %}
  <div class="wishlist-status">
    <p>You have <strong>{{ wishlist.size }} items</strong> in your wishlist</p>
    <a href="/pages/wishlist">View Wishlist</a>
  </div>
{% endif %}

Show Custom Properties

{% assign properties = customer.metafields.lantern.properties | parse_json %}

{% if properties.favorite_category %}
  <div class="personalized-content">
    <p>Based on your interest in <strong>{{ properties.favorite_category }}</strong>:</p>
    <!-- Show personalized content -->
  </div>
{% endif %}

Display Recent Activity

{% assign activity = customer.metafields.lantern.activity_feed | parse_json %}

{% if activity.events.size > 0 %}
  <div class="recent-activity">
    <h4>Recent Activity</h4>
    {% for event in activity.events limit: 3 %}
      <p>{{ event.metric.name }} - {{ event.timestamp | date: '%B %d' }}</p>
    {% endfor %}
  </div>
{% endif %}