Using Shopify Metafields

How to create and manage metafields to optimally display your product information on Shopify

Metafields are Shopify's answer to custom attributes. They can be applied to different parts of your Shopify store including products, customers, orders, and other objects. This article explains the various types of metafields, what information they can hold, and how to create them in a Plytix Shopify channel.

 

🚀 Plytix is now compatible with Metafields 2.0! 

 

What are metafields?

Types of Metafields

- Metafields Without a Definition

- Metafields With a Definition

Metafield Definitions

Metafield Values

Metafield Lists

 

*Skip to any section in this article by clicking on the links above

 


 

What are metafields?


Basically, metafields are non-required fields that display custom information about your products in Shopify. For example, if you sell bicycles, you may want to display the number of speeds they have. Or if you sell food, then you'll probably need to let buyers know the ingredients they contain. Metafields can also be used internally for things like tracking inventory. There are two types of metafields:

  • Metafields without definition
  • Metafields with definition


Types of Metafields

Originally, Shopify offered three types of metafields (those in bold are currently supported by Plytix):

  • Integer
  • String
  • JSON string


These are what we refer to as metafields without definition, and they are available only for the product level.

On the other hand, metafields with definition are available on a product and variant level. Shopify has 18 different types of metafields with definition (those in bold are currently supported by Plytix):

  • Color
  • Date
  • Date & Time
  • Dimension
  • Weight
  • Volume
  • Integer
  • Decimal
  • Rating
  • Product reference*
  • Product variant reference*
  • File reference*
  • Page reference*
  • URL
  • Single Line Text
  • Multi Line Text
  • True or False
  • JSON String

 

*May or may not be added in the future according to user needs

 

ℹ️ At the moment Plytix only supports product and variant metafields.


Metafields without a definition

These metafields do the same basic thing as metafields with a definition, but they are less specific and require the use of Shopify Liquid code in order to display them in your store. 

Value Type Description Mapping Suggestions
Integer

A whole number.

Example: 200

Match with an integer attribute.
String

A piece of text.

Example: "Made with 100% eco-friendly materials."

Match with a dropdown, multiselect, short text, boolean, or paragraph attribute.
JSON String

A JSON-serializable value. This can be an object, an array, a string, a number, a boolean, or a null value.

Example:


 "value": 25.0, 
 "unit": "cm"

Match with a paragraph or HTML attribute.

Create a new metafield without a definition: 

  1. Go to the 'Metafields' section of your Shopify channel.
  2. Click on 'Create metafield'.
    Create a metafield in the metafields tab in your shopify channel
  3. Select 'No definition'.
  4. Define the namespace and key.
  5. Choose the value type ('integer''string', or 'JSON string').
  6. Click 'Create metafield'.

choose to create a metafield without definition in the form of string, integer or JSON string

Now your metafield will be available for mapping.


Metafields with a definition

The new version of metafields does not require any coding on Shopify's end to customize your product pages and is fully compatible with Shopify 2.0 themes. Create metafields in Plytix, then, if you have a Shopify Online Store 2.0 theme, you can connect most metafields to your theme by using the theme editor.

Value Type Description Mapping Suggestions
Single Line Text

A single line of text.

Example: "Made in the USA"

Match with a short text attribute.
Multi Line Text

More than a single line of text. 

Example: "In life, you can never have enough tote bags! Better yet, ones with cute, unique sayings and made from organic cotton. This large, printed beige bag is ideal for transporting your goodies around in an organized, safe manner. Whether you're going to the beach, having a picnic, visiting the grocery store, or hitting the gym, a tote bag is bound to come in handy when you least expect it."

Match with a paragraph, dropdown, HTML, or multiselect attribute.
Integer

A whole number.

Example: 16

Match with an integer attribute.
Decimal

A number with a decimal point.

Example: 25.99

Match with a decimal attribute.
Color

The hexidecimal code for a color.

Example: #51227f

Match with a short text or dropdown attribute.
Date

A date in ISO 8601 format without a presumed timezone.

Example: 2022-03-21

Match with a date attribute.
Date and Time

A date and time in ISO 8601 format without a presumed timezone.

Example: 2017-08-01T12:15:00

Match with a short text attribute.
Dimension

Either a whole number or decimal value with metric or imperial units of measurement.

Example: 10 cm.

Match with an integer or decimal attribute and a short text attribute for the unit of measurement.
Weight

Either a whole number or decimal value with metric or imperial units of measurement.

Example: 3.5 lbs.

Match with an integer or decimal attribute and a short text attribute for the unit of measurement.
Volume

Either a whole number or decimal value with metric or imperial units of measurement.

Example: 750 ml.

Match with an integer or decimal attribute and a short text attribute for the unit of measurement.
Rating

A decimal value along a given scale, depending on how you configure your definition in Shopify.

Example: 4.7 out of 5 stars

Match with an integer or decimal attribute. 
JSON String

A JSON-serializable value. This can be an object, an array, a string, a number, a boolean, or a null value.

Example:


 "value": 25.0, 
 "unit": "cm"

Match with a paragraph or HTML attribute.
True or False

A true or false value.

Example: True

Match with a boolean attribute.
URL

A URL with one of the allowed schemes: https, http, mailto, sms, tel

Example: https://www.plytix.com/

Match with a URL attribute.

 

Create a new metafield with a definition: 

  1. Go to the 'Metafields' section of your Shopify channel.
  2. Click on 'Create metafield'.
    create a metafield in your Shopify channel by clicking on the metafields tab
  3. 'Definition' is selected by default.
  4. Choose if you want your metafield to apply to the 'Product' or 'Variant'. The main difference here is that by choosing variant, the metafield will not be displayed in the product detail in Shopify.
  5. Define the namespace, definition name and key.
  6. Choose the type of information you want in this metafield from the 'Value Type' dropdown.
  7. You have the option to check the box to 'Expose this metafield to storefront API requests.' If you're not sure about this, leave it unchecked. 
  8. Optionally, add a description for your metafield.
  9. Click 'Create Metafield'.

💡 Don't worry about the definition name you assign to your metafield. Its only purpose is to identify the metafield in Shopify's backend.

create a metafield with definition for products in your shopify channel

Now your metafield will be available for mapping.


 

ℹ️ Currently, Shopify allows merchants to create up to 200 metafield definitions, but you can create an unlimited amount of metafields in Plytix. 

ℹ️  If you want to match an attribute to a metafield that already exists in Shopify, make sure to use the same namespace as the already existing metafield. 

⚠️ The namespace cannot be changed once it is created.


Metafield Definitions

The term "definition" can be a little confusing, but you can think of it as a template for creating a metafield. A metafield definition includes several main components:

  • Namespace - This is like a folder in which to keep your metafields. You can have the same namespace and key for two metafields if one is a product and one is a variant.
  • Key - The name you give your metafield.
  • Description - This is optional, but can help to clarify the purpose of the metafield.
  • Value Type - This determines what type of information the metafield will display
  • Validation Rule (not supported by Plytix) - This determines what information is valid for a metafield, for example, the number or type of characters it can contain. Different types of metafields have different types of validations, so be sure to set these up in your Shopify account.

ℹ️ There's no need to worry about customers seeing metafield namespaces and keys; they are just a way of organizing your metafields.


Metafield Values

To add values to a metafield, you'll need to map your Plytix attributes to each one. For example, if you store you product color in a short text attribute called "Color", then this is the attribute you'll match to your color type metafield by selecting 'Match Metafield' in the 'Metafields' tab of your Shopify channel.

match a metafield to any attribute in Plytix to send product information to Shopify

A panel will appear that offers options for matching a metafield to a Plytix attribute. Here you can select an 'Existing attribute' from the list....

4

... or click 'Create Computed' to make a computed attribute that satisfies the metafield's validation rule if needed.

create a computed attribute to match to your Shopify metafield if you need to add a value that is not stored in Plytix

If matching a metafield to a computed attribute, you'll need to complete one more step: add a formula using an operation to transform your stored attributes. After you click 'Test and Apply', the formula will appear in the "Formatting" section of your metafield.

The formula of your custom attribute can be seen under the formatting section of metafields with definition

After matching all of your metafields, click 'Save Changes' at the top of your channel. Process the channel to push your new metafields through to Shopify.

 


Metafield Lists

When you create a metafield with definition, you may choose either a single value or a list of values. This option is only available for metafields with the supported value types:

  • Single line text
  • Integer
  • Decimal
  • References (Product, product variant and page)
  • File
  • Color
  • Rating
  • URL
  • Weight
  • Volume
  • Dimension
  • Date
  • Date and time

Additionally, some value types require units of measurement, so you'll need to match additional attributes to unit lists for these values.

  • Weight
  • Volume
  • Dimension

ℹ️ You may use up to 128 attributes in a metafield list. This is a limit created by Shopify.

 

To create a metafield list:

1. Click 'Create metafield' and give your new metafield a name. Leave 'Definition' selected.

2.  Next, select whether the list will be a 'Product' or 'Variant' metafield. Add a namespace, definition name and key for your reference.

3. Select a 'value type' from the dropdown, then select 'List of values'.

4. Click 'Create Metafield'.

4

5. Now you'll select which attributes to add by clicking '+ Add attributes'.

6. Once you've selected your attributes, you can drag and drop them to change their order. When you are ready, click 'Apply'.

5

7. Your metafield list now appears with your other metafields, but it can be distinguished by the "LIS" that appears at the start.

6

8. Some lists also require units of measurement. To add these, select 'Match unit list'.

7

9. Click on '+ Add attributes' and select attributes for your units of measurement, then drag and drop to match the order of your previously matched attributes. Click 'Apply'.

8

10. Your completed metafield list appears with the attributes you matched (hover to see attributes), and your units of measurement (hover to see units), if applicable.

9


 

What's next?

 

If you have any questions just click on the chat box in the bottom-right corner and we'll be happy to answer them...

 

and please let us know 👇