Skip to main content
This guide covers the basics of reading Mage Loyalty metafields in your Shopify Liquid templates.

Accessing JSON metafields

Mage metafields are stored as JSON. In Liquid, you access the parsed data through the .value property:
Once assigned to a variable, you can access nested properties using dot notation:

Checking if metafields exist

Always check that a metafield exists before using it. This prevents errors on pages where the data may not be available:
For customer metafields, also ensure the customer is logged in:

Iterating over arrays

Earning rules, rewards, and VIP tiers are arrays. Loop through them with for:

Displaying rewards

Combining shop and customer data

A common pattern is to show the customer how close they are to a reward: