Where custom data is stored
Customer Fields saves custom data in its own database and in Shopify customer metafields. Each custom data column is saved to a metafield on the customer in Shopify.
You can read metafields in the Shopify admin with metafield definitions, through Shopify's Admin API, or with Liquid in your theme and Shopify's email notifications. This article covers Liquid.
Standard fields, like first_name, email and phone, are saved to the customer's own properties, not metafields. To show them, see Shopify's Liquid customer object.
How metafields are stored
Customer Fields saves each custom data column to its own metafield. This is called Shopify admin-compatible storage, and every new install uses it.
Some older stores still use bundled storage, which saves all custom data in one JSON metafield. If your store does, you'll see Metafields under Settings in Customer Fields, where you can switch. See Metafield definitions in Shopify.
Liquid syntax
Use the syntax that matches your storage and where you're adding the code. Replace NAMESPACE and DATA_COLUMN_KEY with your data column's values.
Shopify admin-compatible
Theme (storefront):
customer.metafields.NAMESPACE.DATA_COLUMN_KEY.value
Email notifications:
customer.metafields.NAMESPACE.DATA_COLUMN_KEY
New data columns use the namespace app--960624--helium by default. Older data columns may use customer_fields. You can check each column's namespace on the Data columns page, or change it for a field. See How to use custom namespaces in Customer Fields.
Bundled JSON metafield (older stores only)
customer.metafields.customer_fields.data["DATA_COLUMN_KEY"]
Formatting with Liquid filters
Each data column has a data type, so you can use Liquid filters to format its value, or read attributes from it, like a file's URL.
Examples
These examples show data for a signed-in customer on the storefront, using the app--960624--helium namespace.
1) Display value for a custom single_line_text data column with the key of favorite_color
Favorite color: {{ customer.metafields.app--960624--helium.favorite_color.value }}
<!-- Outputs:
Favorite color: Orange
-->
2) Display value for a custom date data column using a Liquid date filter to control the format
Your Birthday: {{ customer.metafields.app--960624--helium.birthday.value | date: "%b %d, %Y" }}
<!-- Outputs:
Your Birthday: Feb 06, 1945
-->
3) Display value for a custom list data column using a Liquid filter to convert the array into a comma-separated string
Your Hobbies: {{ customer.metafields.app--960624--helium.hobbies.value | join: ", " }}
<!-- Outputs:
Your Hobbies: Cycling, Hiking, Video Games
-->
4) Display value for a custom file data column using the URL attribute to embed an image
Profile pic: <img src="{{ customer.metafields.app--960624--helium.profile_pic.value.url }}" style="max-width: 150px;">
<!-- Outputs:
Profile pic: <image> (150px max width)
-->
5) Display values for a custom file data column using the URL and name attributes for a hyperlink
PDF agreement: <a href="{{ customer.metafields.app--960624--helium.contract.value.url }}" target="_blank">{{ customer.metafields.app--960624--helium.contract.value.name }}</a>
<!-- Outputs:
PDF agreement: <filename> (hyperlink that opens file URL in a new tab)
-->
6) Display values for a custom group_list data column using a for-loop to output certain data attributes in the array of objects
{% for pet in customer.metafields.app--960624--helium.pets.value %}
<p>Pet name: {{ pet.name }}</p>
<p>Pet weight: {{ pet.weight }}</p>
<br>
{% endfor %}
<!-- Outputs:
Pet name: Franklin
Pet weight: 30 lbs
Pet name: Winston
Pet weight: 2 lbs
--->
7) (Advanced) Display values for a custom group_list column using a variable, multiple filters, iteration, and some control flow logic
{% assign pets = customer.metafields.app--960624--helium.pets.value %}
<h4>Your Pets ({{ pets | size }} total)</h4>
{% for pet in pets %}
<ul>
<li>{{ pet.name | capitalize }} ({{ pet.type | downcase }}), {{ pet.energy_level | downcase }}</li>
{% if pet.birthday != nil %}<li> Born: {{ pet.birthday | date: "%b %d, %Y" }}</li>{% endif %}
<br>
</ul>
{% endfor %}
<!-- Outputs:
Your Pets (2 total)
Franklin (dog), lazy
Born: Oct 10, 2015
Winston (hamster), active
--->
For more technical details, see the developer documentation.
Related articles
Need help with Liquid? Chat with us or email support+cf@heliumdev.com.
