All things Shopify and commerce
I'm trying to add variant-specific metafields to my Shopify product JSON-LD structured data to ensure that each variant gets properly indexed and displayed in Google's rich results.
I have the following metafields at the variant level:
I'm currently including these metafields in the offers section of the JSON-LD for each variant like code attached
"offers": [
{%- for variant in product.variants -%}
{
"@type": "Offer",
"price": "{{ variant.price | money_without_currency | replace: ',', '.' }}",
"priceCurrency": "{{ shop.currency }}",
"itemCondition": "https://schema.org/NewCondition",
"url": "{{ shop.secure_url }}{{ variant.url }}",
"sku": "{{ variant.sku }}",
"mpn": "{{ variant.barcode }}",
"availability": "https://schema.org/{%- if variant.available -%}InStock{%- else -%}OutOfStock{%- endif -%}",
"priceValidUntil": {{ "today" | date: '%s' | plus: 2592000 | date: "%Y-%m-%d" | json }},
"customAttributes": {
"strain": "{{ variant.metafields.custom.strain }}",
"strainType": "{{ variant.metafields.custom.strain_type }}",
"category": "{{ variant.metafields.custom.category }}",
"strainGenetics": "{{ variant.metafields.custom.strain_genetics }}",
"strainDescription": "{{ variant.metafields.custom.strain_description | strip_html }}",
"thcPercentage": "{{ variant.metafields.custom.thc_percentage }}",
"strainEffects": "{{ variant.metafields.custom.strain_effects }}",
"thirdPartyTestResults": "{{ variant.metafields.custom.3rd_party_test_results }}"
}
}{%- if forloop.index < product.variants.size -%},{%- endif -%}
{%- endfor -%}
]
:
The issue I'm encountering is that Google's Rich Results Test either fails to recognize multiple variants or shows only one variant without detecting any of the added metafields (customAttributes).
What am I doing wrong in incorporating these variant metafields in the JSON-LD? Is there a specific format or practice that ensures variant-specific data is properly picked up by Google's schema validation tools? Any insight or best practices for handling variant metafields in Shopify JSON-LD would be greatly appreciated.
Thanks in advance for any help!
Give it a try: https://feedarmy.com/kb/shopify-microdata-for-google-shopping/
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025