Help for fix my JSON script

Annavittoria
Excursionist
37 0 17

Hello,

I'm wondering if anyone can help me in order to fix my JSON script into the product.liquid.

Running some tests, data results are complete into the google merchant center, but not if I run a rich result test. In particular, I'm missing the following fields:

  • review - (I guess because I don't have any product review available)
  • aggregateRating - (same as previous)
  • gtin
  • mpn
  • isbn
  • priceValidUntil

Herebelow I'm attaching my product.liquid

{% comment %}
  The contents of the product.liquid template can be found in /sections/product-template.liquid
{% endcomment %}

{% section 'product-template' %}
{% section 'feature-columns-custom' %}
{% section 'product-recommendations' %}

{% if collection %}
  <div class="text-center return-link-wrapper page-width">
    <a href="{{ collection.url }}" class="btn btn--secondary btn--has-icon-before return-link">
      {% include 'icon-arrow-left' %}
      {{ 'products.product.back_to_collection' | t: title: collection.title }}
    </a>
  </div>
{% endif %}

<script>
  // Override default values of shop.strings for each template.
  // Alternate product templates can change values of
  // add to cart button, sold out, and unavailable states here.
  theme.productStrings = {
    addToCart: {{ 'products.product.add_to_cart' | t | json }},
    soldOut: {{ 'products.product.sold_out' | t | json }},
    unavailable: {{ 'products.product.unavailable' | t | json }}
  }
</script>

{% assign current_variant = product.selected_or_first_available_variant %}

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
  "name": {{ product.title | json }},
  "url": {{ shop.url | append: product.url | json }},
  {%- if product.featured_media -%}
    {%- assign media_size = product.featured_media.preview_image.width | append: 'x' -%}
    "image": [
      {{ product.featured_media | img_url: media_size | prepend: "https:" | json }}
    ],
  {%- endif -%}
  "description": {{ product.description | strip_html | json }},
  {%- if current_variant.sku != blank -%}
    "sku": {{ current_variant.sku | json }},
  {%- endif -%}
  "brand": {
    "@type": "Brand",
    "name": {{ product.vendor | json }}
  },
  "offers": [
    {%- for variant in product.variants -%}
      {
        "@type" : "Offer",
        {%- if variant.sku != blank -%}
          "sku": {{ variant.sku | json }},
        {%- endif -%}
        "availability" : "http://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}",
        "price" : {{ variant.price | divided_by: 100.00 | json }},
        "priceCurrency" : {{ cart.currency.iso_code | json }},
        "url" : {{ shop.url | append: variant.url | json }}
      }{% unless forloop.last %},{% endunless %}
    {%- endfor -%}
  ]
  } 
 </script>

<!-- IORelatedProduct -->
<div id="io-related-prd-id" style="float: left; clear: both; width: 100%" data-id="{{product.id}}"></div>{{shop.metafields.grrelated_ns.grrelated_key}}

Here a link of a product if you want to run a test by yourselves https://www.pianodgirls.com/products/copia-di-tuta-palazzo-con-manica-fuxia-rinascimento?variant=394...

Any help for implement all the missing fields into the script?

Thanks in advance

Replies 3 (3)
EmmanuelFlossie
Shopify Partner
1227 65 288

The easiest way is to remove your existing code, and install the code shown in the tutorial here: https://feedarmy.com/kb/shopify-microdata-for-google-shopping/

I'm a Google Shopping Specialist and a Google Ads Diamond Product Expert (Only 9 Google Ads Diamond Experts in the world!), also I'm a Google Premier Partner
. Need Premium Data Feed Management Support? Get in touch.
Annavittoria
Excursionist
37 0 17

@EmmanuelFlossiethanks for your reply

I tested and kinda works, but it returns some error you should fix in the script:

  • "brand": {
    "@type": "Thing",
    "name": "{{ product.vendor | escape }}"} - "Thing" is incorrect and should be replaced with "Brand"
  • the SKU valor returns the google merchant ID and not the actual SKU applied from the user, i don't think this is correct
EmmanuelFlossie
Shopify Partner
1227 65 288

1) Reload the page, (Hard refresh) you might be seeing an old version, Brand was updated a few weeks ago. Latest version is 3.08

2) You can change the value by following the setting options, reference: 

The following step requires you to check the product id in Google Merchant Center > Products > List. And see what ID you are using.

  • If it looks like shopify_US_81191654332_1055121650148, then keep fa_product_id set to default
  • If it looks like 1055121650148 then set the value fa_product_id to product_id
  • If it looks like the main id 81191654332 then set the value fa_product_id to parent_id
  • If it looks like a sku then set the value fa_product_id to sku

Let me know if you have any further questions, and happy to help.

I'm a Google Shopping Specialist and a Google Ads Diamond Product Expert (Only 9 Google Ads Diamond Experts in the world!), also I'm a Google Premier Partner
. Need Premium Data Feed Management Support? Get in touch.