Skip to content

Shopify tutorials for the person running the store. Orders, discounts, fulfilment, returns.

Add a customer metafield in Shopify

Shopify's customer profile has no built-in field for a loyalty tier or a points balance. A metafield adds one: a named slot for a single fact, with a type that keeps the values clean. This tutorial creates two customer metafields, Loyalty tier and Points balance, and fills them in for three customers.

Written · Shopify admin, desktop steps · 4 minutes read

The worked example

Metafield definitions2
Customers with values3
Points balance total545
Average points balance181.67
Loyalty tiers in use3

Download the metafield values sheet: customer-metafield-values.csv (111 bytes, md5 4b3a26bf5661b7e40db9e3bf0eff1bb1).

A sheet of the metafield values from this tutorial: loyalty tier and points balance for three customers. The points balances add to 545.

1Create the definition

From your Shopify admin, go to Settings, then Metafields and metaobjects, then select Customers, and click Add definition. You can also start from a customer profile: open the customer, go to the Metafields section, and click Add definition.

2Name the field and pick its type

In the Name field, enter Loyalty tier. The Namespace and key fills in automatically as custom.loyalty_tier. Click Select type and choose Single line text. Click Save. A definition names the field, ties it to customers, and sets which values it accepts.

3Create the second field the same way

Add a second definition named Points balance, with the key custom.points_balance and the type Integer. Two definitions, two facts: a tier is text, a balance is a number, and the type keeps them apart.

4Fill in the values on each customer

Open a customer profile, go to the Metafields section, click the field, enter the value, and click Save. Maya Chen is Gold with 320 points, Jordan Lee is Silver with 185, and Priya Patel is Bronze with 40.

5Use the field in a segment or a bulk edit

Customer metafields can be used as segment filters and can be edited in the bulk editor alongside first name, last name, tags, and email. They can also be added to a customer CSV as a column matching the namespace and key, such as customer.metafields.custom.points_balance.

The arithmetic

Three customers, two metafields each.

CustomerLoyalty tierPoints balance
Maya ChenGold320
Jordan LeeSilver185
Priya PatelBronze40
Total3 tiers545

320 plus 185 plus 40 equals 545 points. The average balance is 545 divided by 3, which is 181.67 points. Each customer holds one of three tiers: Gold, Silver, or Bronze.

Held at the counter

A value needs a definition first. There is no free-form metafield on a customer without a definition behind it. Create the definition, then fill in values; the profile shows nothing to fill in before that.

Only some types travel by CSV. Boolean, date, date and time, integer, decimal, and single line text metafields can be imported and exported in a customer CSV. A file or image metafield cannot, so do not plan a bulk load around one.

The namespace and key must be unique. Two definitions cannot share custom.loyalty_tier. If the key is taken, Shopify will not save the second definition, and the fix is a different name, not a second try with the same one.

Sources