Skip to main content
[Shopify] Metafields
Success team avatar
Written by Success team
Updated over 3 months ago

Shopify metafield sync is available for Shopify mechants on our Classic plan and above.

What are metafields?

LoyaltyLion can push customer properties to Shopify customer metafields when a customer changes. For example, when a customer earns points we can update a metafield on the corresponding customer resource in Shopify.

Metafields can be accessed in Liquid templates as well as from the API, which enables some powerful integrations and custom interfaces.

LoyaltyLion fields

The following fields can be pushed as customer metafields. You can enable or disable the exact metafields we'll push from the Integrations section of the LoyaltyLion admin. 

Description -  Example  - Metafield name

Total points -  1000 - loyaltylion.points_total 

Approved points  - 800 - loyaltylion.points_approved 

Pending points - 200 - loyaltylion.points_pending 

Lifetime points  - 2000 - loyaltylion.points_lifetime 

Spent points  - 1000 - loyaltylion.points_spent 

Number of rewards claimed - 3 - loyaltylion.rewards_claimed 

Date enrolled in program (YYYY-MM-DD)  - 2017-09-20 -  loyaltylion.enroll_date 

Referral URL -  http://prz.io/KzByQ2Fa -  loyaltylion.referral_url 

Loyalty Tier  - Silver - loyaltylion.loyalty_tier 

Loyalty Tier (customer tag) - tag: Silver

Birthday (YYYY-MM-DD)  - 1970-03-15 - loyaltylion.birthday

How to integrate Shopify metafields?

  1. Login to your LoyaltyLion account

  2. Click on the tab Manage

  3. On the left, find Integrations and click Manage

  4. Find Shopify on the list and click Install Integration button

  5. Click Enable Shopify sync

  6. Done! Now you can move to your Shopify admin and add definitions.

Steps for filling in the metafields

You will need to fill in the metafields to show the customer's LL data in Shopify.

  1. Go to Settings in Shopify -> Custom data -> Customers and select View unstructured metafields

  2. After clicking Add definition for one of the LoyaltyLion fields :

    1. Add a Name

    2. Click Select Type, and select the correct type for the field as per the screenshot below

    3. Do not add any Validations

    4. Make sure the Storefronts access under Options is set to Read

    5. The metafield should then look like the below screenshot

    6. Save the metafield

    7. Continue steps a through f for the remaining LoyaltyLion unstructured metafields

Make sure to set the definitions types as per screenshot. Otherwise, the integration won't work as expected.

Do not put validations when creating metafields.​

3. After saving, the metafield appeared in Definitions with the added “customer.metafields”.

Using metafields

Within Liquid templates

You can reference metafields in most Liquid templates like so:

{{ customer.metafields.loyaltylion.points_total }}

For example, to display the customer's unique referral link:

 referral url: #{{ customer.metafields.loyaltylion.points_total }} 

Caveats

Although we generally sync metafields straight away, usually within a few minutes of a customer changing in LoyaltyLion, the sync can be delayed, particularly if many customers change at once, due to Shopify API rate limit restrictions.

If you're using metafields in an integration or in a template, you should account for their values being slightly out of date, or, in the case of new customers, blank.

References

FAQ

Q. What's the difference between Loyalty Tier and Loyalty Tier (customer tag)?

Loyalty Tier syncs a metafield, which can be referenced in your Shopify theme.

Loyalty Tier (customer tag) adds a tag, which appears in the customer profile.

Did this answer your question?