Where is customer data stored?

Customer Fields stores custom data in two places; the app's database and Shopify’s metafields

When a customer record is saved, and the data being saved contains values for custom data columns, then the app will store metadata on the Customer resource/object in Shopify using metafields. The app's metafields are designed to use customer_fields as the namespace, and data as the key. This metafield data is accessible via the Shopify API, or on the front-end using Liquid.

The latest version of Customer Fields saves all of the metafield data in a single JSON string. The value of the string contains the app's data column keys and respective data column values. Please note that metafields are only used for custom fields; data for standard fields (e.g. first_name, email, phone, etc) will be saved to the normal places within Shopify.

Liquid output

By editing a store's theme code or Shopify's email notification templates, you can use Liquid to access custom data collected by Customer Fields.

Syntax

To access custom data on the storefront or in email notifications, you will need to use the following syntax:

{{ customer.metafields.customer_fields.data["DATA COLUMN KEY"] }}

Note: You'll need to replace DATA COLUMN KEY with the actual data column key you wish to use.

Liquid-friendly data types

Since each data column in Customer Fields has its own specific 'type', you can apply data-specific filters to format the data, or even scope out certain data attributes.

Below you'll find several different examples of how to display metafield data for a customer:

Specific examples

1) Display value for a text data column with the key of 'pet_name':

Your pet's name: {{ customer.metafields.customer_fields.data["pet_name"] }}

<!-- Outputs:
Your pet's name: Franklin
-->

2) Display value for a date data column using a Liquid date filter to control the format:

Your Birthday: {{ customer.metafields.customer_fields.data["birthday"] | date: "%b %d, %Y" }}

<!-- Outputs:
Your Birthday: February 6, 1945
-->

3) Display value for file data column using the URL attribute to embed an image:

Profile pic: <img src="{{ customer.metafields.customer_fields.data["profile_pic"].url }}" style="max-width: 150px;">

<!-- Outputs:
Profile pic: <image> (150px max width)
-->

PDF agreement: <a href="{{ customer.metafields.customer_fields.data["contract"].url }}" target="_blank">{{ customer.metafields.customer_fields.data["contract"].name }}</a>

<!-- Outputs:
PDF agreement: <filename> (hyperlink that opens file in a new tab)
-->

5) Display values for a group list data column using a for-loop to output certain data attributes in the array:

{% for pet in customer.metafields.customer_fields.data.pets %}
Pet name: {{ pet.name }}
Pet weight: {{ pet.weight }}
{% endfor %}

<!-- Outputs:
Pet name: Franklin
Pet weight: 30 lbs
Pet name: Winston
Pet weight: 2 lbs
--->

6) (Advanced) Display values for a group list column using a variable, multiple filters, iteration, and some logic:

{% assign pets = customer.metafields.customer_fields.data.pets %}
<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: October 10th, 2015

Winston (hamster), active
--->

Looking for more technical details? 🤓

Learn more about the app's metafields using our Developer Documentation.

Did this answer your question?