Connect Metafields to Tags

is there a way i can automatically fill metafields by reading tags for example if a tag is 6Y

can metafields be 6 years?

There are many ways to do it

first way is to add this code in your product template file

{% if product.metafields.custom.age %}

<p>{{ product.metafields.custom.age }} years</p>
{% endif %}

another way is to use javascript code

const ageTag = product.tags.find(tag => tag.match(/^\d+Y$/));
if (ageTag) {
const age = parseInt(ageTag);
metafield.value = age;
}

let me know if it’s working for you or not

Where can i add it?

and i have my tags for exampe 6Y is for 6 years, 7Y 7 years how do i add more the n 18 tags to t in this case?

How many products you have?
Who/what changes the tags?
How many tags you need to monitor?
How fast do you need the metafields updated?

Technically you can use Flow (free app) with Flow assistant (paid app) to run flow on “product tags added/removed” trigger and add/remove metafield.

If you do not mind daily/hourly updates and/or less than 100 products, it’s easy to do with Flow only.

i have 3400 products , we add the tags, we need to ensure each tag is in the right product

i have 3400 products , and i need them to be updated at all times , for filtration purposes

Go to:
Online Store → Themes → Edit Code
search and open this file sections/main-product.liquid

then inside this div ()
insert this code

{% if product.metafields.custom.age %}

<p>Age: {{ product.metafields.custom.age }} years</p>
{% endif %}


another way:

{% assign age = ‘’ %}

{% for tag in product.tags %}
{% if tag contains ‘Y’ %}
{% assign age = tag | remove: ‘Y’ %}
{% endif %}
{% endfor %}

{% if age != ‘’ %}

<p>Age: {{ age }} years</p>
{% endif %}

Then I’d recommend to

Unfortunately, Flow itself does not have “product tag added/removed” trigger, this is why you’d need a “companion” app.

Flow would be like this:


Alternatively, you can use only Flow, but update would not be immediate, say it will take up to half an hour:
the flow will run every 30 minutes, retrieve a list of products which has tag “7y” but do not have metafield set to “7 years” and set metafield on each of these products:


Those are basic flows to start with – there needs to also be a check if metafield is set, but tag is not, so remove the metafield;
and repeat for each tag/mf pair you want to monitor.

can we do a google meet call to help me with this ?

@mastrokmastrok if i add the first one as u said o i add it anywhere? also if something is 6Y as a tag does it read it as 6 years?Loom Message - 22 April 2026 | Loom

yes sure, happy to help

looking over your video give me some time

search for this div tag

<div class="product__info">

let me know if it works for you or else we can do a meet and we will assist you

How can we connect ?

Can we do a meet because I need to understand how all the tags or years will be read when they r different

If you’d like assistance resolving this—especially since it involves a custom implementation—we’d be happy to help. You can visit our profile to learn more about it and book a meeting at a time that works best for you.

Use the Shopify flow app with trigger “Product Created/Updated” → Run code to transform the tag into readable formant(6Y->6 Years)-> Update Product metafield. use the metafield for filtering.

You can ask Sidekick to do this for you.

The only problem is that there is no “Product updated” trigger in Flow.

You are right, there is only Product Created and Product status updated. The Flow companion is the right choice here.