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/
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024