Shopify: Tags vs. Metafields

9th Jul 2016

This post is the beginning of a series of technical notes and tutorials on Shopify. Shopify is an eCommerce platform built with merchants in mind, check it out!

Storing data in Shopify is straightforward and tailored for eCommerce. There's usually a ready-made parameter for any data relating to an object that you'd need to store. However, there are instances where further data about a product, collection or customer might be useful.

When handling additional object data in Shopify, you usually have one of two options:

  • Tags - a short string descriptor
  • Metafields - a namespaced key-value pair

Tags are cheap and easy to use - this is because they are treated as "first class" citizens when retrieving products, collections, blogs, articles, customers and orders. They require no additional API calls and are returned as a comma-seperated string on the object result. They'll show up in the admin panel and can be added and removed as part of a single object update.

Metafields are more complex in that they require separate API calls in order to retrieve their contents - you'll need to know what you're looking for. They can hold more complex data in a structured way using namespacing. They're also useful if you want to store "additional" data that a merchant might not need to see and they can be attached to just about anything.

If you want to find out more about Metafields, check out their API reference page or look at the suite of tools for using Metafields in your store from Freakdesign.

Understanding the distinctions between tags and metafields might save you a bit of time later on. The rules I usually go by - if there's a mission critical function or a need to quickly search through the data - go with Tags. If we need to store relationships between fields, restrict visibility or configure a field for the store owner to use with Custom Fields - go with Metafields.