Shopify Metafield Basics: Managing and Importing Simplified
At first glance, Shopify might seem limited in customizing product pages, but that’s not the case. The platform offers metafields, a convenient and intuitive tool to highlight the unique features of each product. Metafields allow you to adapt a standard product page to suit any specific needs, making customization easy. Below, we explore the basics of Shopify metafields – an integral part of the Shopify admin and storefront.
In this article, you’ll discover what a Shopify metafield is and explore the various types of metafields available. Following that, we’ll provide a detailed step-by-step guide on adding metafields to a product page in Shopify. Lastly, we’ll cover how to import metafields into Shopify, ensuring you can seamlessly integrate this powerful feature into your store.
Table of contents
What is Metafield in Shopify?
Shopify uses the following parts to define metafields:
- Namespace and key – the combination of namespace and key is a unique identifier for your metafield. Namespace and key should be separated by a “.”, and can only contain letters, numbers, underscores (_), and hyphens (-). Use a namespace to group similar metafields. E.g., namespace products + the keys expiration_date and rating. The namespace and key combination must be unique.
- Value – this part characterizes the type and format of information that’s contained in your metafield. E.g., plain text, URL, or integer. Note that each metafield type is associated with specific values.
- Description – it is an optional component of a Shopify metafield that can help you input the correct values in the admin.
- Validation – it is another optional parameter used to limit the values that your metafield can contain.
Shopify Metafield Types
Now, let’s look at the different types of Shopify metafields. Each type is suitable for specific situations, as they accept a range of supported values. Below is a table showcasing the most common Shopify metafield types, their supported values, and example use cases:
Metafield Type | Description | Example |
Collection reference | Link to an existing collection. Supports linking to one or multiple collections in a metafield list. Can be used in a list. | Include a “Complete the look” collection for fashion products on your online storefront. |
Color | RGB values in #RRGGBB format. Can be used in a list. | Store the color of a product and set the product page background to the same color. |
Date | Date values in ISO 8601 format, without a time zone. Can be used in a list. | Use this Shopify metafield type to add product expiration dates, order delivery dates, or customer birth dates. |
Date and time | Date values in ISO 8601 format and time values in UTC. Can be used in a list. | Use it for launch events or product release dates. |
Decimal | Decimal values in the range of +/-9999999999999.999999999, with up to 13 digits before the decimal and up to 9 digits after. Can be used in a list. | Use this Shopify metafield to add a carat weight for jewelry. |
Dimension | Dimensions in metric or imperial units of measurement. Both whole number and decimal values are supported. Can be used in a list. | Use it for box heights or product lengths, such as the length of a scarf. |
File reference |
Can be used in a list. |
You can use it to add a PDF file for assembly instructions or a video guide instead. |
Integer | Integer values in the range of -4,611,686,018,427,387,904 to 4,611,686,018,427,387,903. Can be used in a list. | For instance, it can be a page count for books. |
JSON | Raw JSON data for advanced use cases. Cannot be used in a list. | With this Shopify metafield, you can add a table of specifications that has different columns for each product. |
Metaobject reference | A link to a single or multiple metaobject entries. Can be used in a list. | Add and display a custom influencer profile. |
Mixed reference | References of any type. Developer support is needed. Can be used in a list. | Use it for dynamic landing pages. |
Money | Whole numbers and decimal values are supported. The currency code must match the store currency. Cannot be used in a list. | Track product cost details, such as distributor cost or ship-to-warehouse cost. |
Multi-line text | Plain text with line breaks. Cannot be used in a list. | Use it to place shipping notes or return policies on product pages. |
Page reference | A link to an existing page. Linking to a single or multiple pages in a metafield list is possible. Can be used in a list. | Add your policy page or a detailed care guide to product pages. |
Product reference | Linking to one or multiple products in a metafield list. Can be used in a list. | Store and display featured products on product pages or collection pages. |
Product variant reference | Linking to one product variant. Can be used in a list. | Store and display other clothing items in the same color on product pages. |
Rating | Supports decimal values along a given scale. Can be used in a list. | Display an audience score or a star rating for a product. |
Rich text | Text with line breaks and inline styling.
Can only be connected to theme settings that work with rich text. Cannot be used in a list. |
Add long-form stories with styling about your brand or product. |
Single line text | Plain text with no line breaks. Limit single-line fields to preset choices. Can be used in a list. | Use this Shopify metafield to add short notes and announcements to store pages. |
True or false | A checkbox for selecting whether a condition is true or false. Cannot be used in a list. | Add this metafield to let customers select additional services, such as engraving. |
URL | HTTP, HTTPS, and mailto: URLs. Can be used in a list. | Add a link to book reviews or product videos. |
Volume | Whole numbers and decimal values in metric or imperial units of measurement. Can be used in a list. | Specify the volume capacity of a water bottle. |
Weight | Whole numbers and decimal values in metric or imperial units of measurement. Can be used in a list. | Specify the weight of a product or ingredient, for example, grams of sugar. |
This table provides a comprehensive overview to help you choose the appropriate metafield type for your needs.
How to Add a Metafield to a Product
Adding metafields to products in Shopify involves three main steps:
- Create a metafield in your store admin.
- Add it to products.
- Display it on product pages.
Let’s say you run a furniture store with products that share parameters like materials, designers, and dimensions. Here’s how you can display these details on your product detail pages:
Create a Metafield
You can prepare a new Shopify metafield in the store admin under Settings -> Custom data as follows:
- Proceed to the Metafields section;
- Select Products;
- Click on “Add definition”.
- Enter a metafield name (i.e., Material), namespace & key, and description;
- Select a Shopify metafiled type (i.e., Single line text);
- Configure other parameters: decide whether it is a one-value definition or a list of values, specify character count, etc.
- Repeat these steps to create as many new metafields as your case requires.
To save time, you can use the “Limit to preset choices” in the Validations section of the metafield definition. Activate the feature and provide the options for this metafield.
Now, you won’t need to type these values every time you configure a product in your Shopify admin, selecting them from the drop-down instead.
Add It to a Product
Once you create all the necessary metafields, add them to your products – chairs in our example. Follow these steps to add metafields to a product in Shopify:
- Go to your Admin > Products;
- Locate a product for which you want to add metafields;
- Scroll to see available Shopify metafields;
- Specify relevant data for this particular product;
- Add as many metafields as your product requires.
- Repeat these actions for other products.
- Click “Save“.
Product Page Display
During this final step, you will learn how to display the information from metafields on a product page in Shopify. Follow these steps:
- Go to Admin > Online Store > Themes > Customize;
- Select Products > Default product in the top-middle template menu;
- Add a new block under the Product page;
- Click on the “burger” icon to add metafields content.
That’s how you can add the metafields, displaying them in any way you like.
Shopify Metafield Import & Export
Let’s see how to import and export metafields to Shopify. You need the
Import
Below, we explain the Shopify metafield format suitable for import, update scenarios, metafield columns, and the actual data transfer procedure.
Column Format
When it comes to the Shopify metafield import, your update file should have columns with the meatafield data that follow this structure:
mf_<namespace>.<metafield key>
Update Scenarios
Next, the following processes are at your service:
- You can use the import to update metafield values in Shopify;
- You can use the import to create a product with metafields;
- You can use the import to clear metafield values. Place metafield values in a quotation mark (“”).
Note that Shopify cannot delete product metafields in bulk.
Columns & Values
The following table contains examples of Shopify meatafield columns and their values suitable for import:
Content Type | Attribute | Value Example |
Multi-line text | mf_custom.test_ml_text | Test text |
Integer | mf_custom.test_int | 5 |
Decimal | mf_custom.test_dec | 4.0 |
Product | mf_custom.test_entity | gid://shopify/Product/7682399010997 |
File | mf_custom.test_file | gid://shopify/MediaImage/29058352742581 |
Date and time | mf_custom.test_datetime | 2024-03-05T18:00:00Z |
Date | mf_custom.test_date | 2024-03-06 |
Dimension | mf_custom.test_dim | {“value”:5.0,”unit”:”MILLIMETERS”} |
Weight | mf_custom.test_weight | {“value”:4.0,”unit”:”GRAMS”} |
Volume | mf_custom.test_volume | {“value”:7.0,”unit”:”MILLILITERS”} |
True or false | mf_custom.test_bool | true |
Color | mf_custom.test_color | #59ca22 |
Rating | mf_custom.test_raiting | {“scale_min”:”1.0″,”scale_max”:”10.0″,”value”:”4.0″} |
URL | mf_custom.test_url | https://admin.shopify.com/store/firesync1/products/7682412871861 |
Money | mf_custom.test_money | {“amount”:”4.00″,”currency_code”:”EUR”} |
JSON | mf_custom.test_json | {“name”:”John”,”age”:30,”car”:null} |
Rich text | mf_custom.test_rich_text | {“type”:”root”,”children”:[{“type”:”paragraph”,”children”:[{“type”:”text”,”value”:”test”}]}]} |
Single line text | mf_custom.test_single_line_text | Test text |
Collection | mf_custom.test_collection | gid://shopify/Collection/236417155253 |
Product variant | mf_custom.test_product_variant | gid://shopify/ProductVariant/43712193462453 |
Metaobject | mf_custom.test_meta_object | gid://shopify/Metaobject/56229429429 |
Page | mf_custom.test_page | gid://shopify/OnlineStorePage/73557213365 |
Import Workflow
When your update file is prepared, run a standard product import associated with the Import & Export Tool.
- Proceed to Apps -> Firebear Import & Export Tool -> Import;
- Hit the”Import” button to create a new import profile for Shopify metafields.
- Now, apply basic configurations to initiate the update:
– Name your import profile;
– Choose an entity: Product;
– Select a file type: CSV, XML, XLSX, or Google Sheets;
– Choose a file source: file upload, URL upload, FTP transfer, or Google Drive import;
– Provide a file with Shopify metafield data to import.
- You don’t need to do anything with your mapping section if your update adheres to the Shopify requirements.
- Click the “Save” button to save your import profile. Next, click the “Import” button to import metafields to Shopify.
Export
As for the Shopify metafield export, it is also a basic product export workflow associated with the Import & Export Tool. Follow these steps to transfer metafields data from your e-commerce website:
- Create a new export profile: go to Shopify Admin -> Apps -> Firebear Import & Export Tool -> Export and click the “Export” button.
- Configure basic export parameters:
– Select an entity: Product;
– Choose a destination: File, FTP, Google Sheets, or Google Drive;
– Select a file type: CSV, XLSX, XML, or Google Sheets;
– Choose a lower bunch size value for low-end servers and a higher value for high-end servers. - Create filters if you don’t want to export all records. transfer only particular products with metafields.
- Use the mapping screen to export only the columns essential for your update. Rename all the default Shopify columns, specifying any new custom names. Unselect the columns that you don’t need.
- Click the “Save & Close” button to save your Shopify metafield export profile and “Export” to transfer metafields from Shopify immediately.
Conclusion
Understanding metafields in Shopify is a relatively complex task that may take time. Therefore, it is recommended to start with simple items and learn the basics. Once you get a grip, managing and importing them becomes essentially simplified; you can create more complex product pages with lots of metafields.
You will be amazed at how much manual work they can save. As you can see, it is also possible to import metafields to Shopify to reduce any manual interactions in this area. For further information on the Shopify metafield import and export, contact us and read our Import & Export Tool Manual.