Adding metafield information from prefixed tags

Topic summary

A user seeks to automatically populate product metafields from prefixed tags (e.g., ‘brand_nike’) using Shopify Flow, since they cannot fully transition to metafields due to collection limitations and listing integrations.

Solution Provided:

  • Flow can extract tag values after a prefix using Liquid code in the ‘Update product metafield’ action
  • Template available: ‘Update a product metafield if a product tag has a certain prefix’
  • Example Liquid: {% for tag in product.tags %}{% if tag contains "brand_" %}{{ tag | remove: "brand_" }}{% endif %}{% endfor %}

Key Limitations:

  • No ‘product updated’ or ‘tag updated’ trigger exists; only works on product creation or status changes
  • Manual backfill possible via ‘Run Flow automation’ under ‘More actions’ for existing products

Common Issues Resolved:

  • Error: ‘Value must be a single line text string’ - caused by empty values or case sensitivity mismatches between Flow conditions and Liquid code
  • Solution: Use exact case matching or normalize with uppercase/lowercase, add hyphens to remove whitespace ({{- tag -}})

Alternative Approach:

  • One user successfully reversed the workflow: setting metafields with predefined options first, then generating tags from metafields to reduce human error
  • ‘Run code action’ template now available as an app-free alternative
Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

Hi Paul, thank you for your help.

Please see the screenshot below. I have installed the “Update a product metafield if a product tag has a certain prefix” template, replaced ‘prefix_’ with ‘brand_’ in the “Check if…” box, entered the relevant Metafield Namespace and Key date, and then replaced ‘prefix_’ with ‘brand_’ within the liquid code within the Value box.

Changing the status of a suitable product then results in the Flow being triggered, it successfully completes the “Check if…” stage but then provides the following error when it reaches the “Update product metafield” stage: "“Value must be a single line text string.” For value: " “”

Thanks again.