Named Tags
The named tags are an optimized alternative to Shopify’s Metafields. Named tags automatically generate key/value attribute pairs from specifically formatted tags.
The primary advantage of named tags is that they don’t require an API call to Shopify’s servers to be retrieved, which makes them way faster to index than metafields.
Enabling named tags
To activate named tags, go to the Products section of the Indexing tab and check the box that says Use named tags.
Shopify limits tags to 255 characters. If you want to index longer strings, you’ll have to use metafields.
Tags, inside Shopify, are stored as long strings
, and are then split on commas. To have commas in your text values, use the encoded
type described below.
Adding named tags
To add a named tag to a product, you must go to that product’s page on Shopify and add a tag with the proper named tag format. Currently, four different types of named tags are accepted:
Default
attr:value
Extracts value
as a string
.
Can’t contain a comma.
Example: author:Isaac Asimov
Boolean
attr:boolean:value
Extracts value
- true or false - as a boolean
.
Example: suitable_for_children:boolean:true
Number
attr:number:value
Extracts value
- integer or decimal - as a number
.
Example: age:number:34
Example: alternative_price:number:199.90
Encoded
attr:encoded:value
Extracts and decodes a URL-encoded value
.
Allows for commas.
Example: alternative_name:encoded:Me%2C%20Myself%20and%20I
To our knowledge, you only need to replace ,
by %2C
, but the URL-encoded approach provides a safe way to make sure all characters will be properly interpreted by Shopify’s tag engine.
To encode your string to this format, you can use:
- an online encoder
- a function built into your programming language, e.g. encodeURIComponent in JavaScript
Restricting named tags to specific variants
Unfortunately, Shopify tags are only available at the product level, so you can’t restrict them to a subset of your variants. However, we provide a workaround with our named tags.
To do this, include a bracketed specifier in front of the named tag: [option_name:option_value]variant_tag:variant_tag_option
.
For example:
- if you want to add the named tag
long_name:Small
to a product’s size S variant, then add the following tag to the product:[size:S]long_name:Small
. - if you want to add the named tag
original_price:number:19.90
to a product’s size S and blue variant, then add the following tag to the product:[size:S][color:blue]original_price:number:19.90
If you have a product with multiple options, e.g. size
and color
, and only specify one of them, the named tag will be applied to all of the matching ones.
To handle long option values, you can use a *
at the end of the value to target all of the option values starting with this string.
For instance, [color:B*]
will apply to both Blue
and Brown
colors.