Google Structured Data (Google Schema Markup)

The aggregateRating is using the Shopify review app.

use this to test: https://search.google.com/structured-data/testing-tool/u/0/

Below is a starting point for the data:

<div class="row" itemscope itemtype="http://schema.org/Product">
    
    <meta itemprop="sku" content="{{product.variants.first.sku}}" />
    <meta itemprop="brand" content="{{product.vendor}}" />
    <meta itemprop="description" content="{{product.description| strip_html}}" />
    {% if product.variants.first.barcode != blank %}
      <meta itemprop="gtin12" content="{{product.variants.first.barcode}}" />
    {% endif %}
    
    <div style="display: none" itemprop="Offers" itemscope itemtype="http://schema.org/Offer">
      <meta itemprop="price" content="{{ product.price | money_without_currency }}" />
      <meta itemprop="priceCurrency " content="{{ shop.currency }}" />
      <meta itemprop="identifier" content="sku:{{ product.variants.first.sku }}" />
      <meta itemprop="url" content="{{product.url}}" />
      <meta itemprop="priceValidUntil" content="{{ 'today' | date: '%s' | plus: 31536000 | date: '%Y-%m-%d' }}" />
      <link itemprop="availability" href="http://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}">
      <meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition"/>
    </div>
    
  {%- assign reviews_value = product.metafields.spr.reviews | split: 'ratingValue" content="' | last | split: '"' |first | plus: 0 -%}
  {%- assign reviews_count = product.metafields.spr.reviews | split: 'reviewCount" content="' | last | split: '"' |first | plus: 0 -%}
  {%- if reviews_count > 0 -%}
    <div style="display: none" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
      <meta itemprop="ratingValue" content="{{ reviews_value }}"/>
      <meta itemprop="ratingCount" content="{{ reviews_count }}"/>
      <meta itemprop="bestRating " content="5"/>
      <meta itemprop="worstRating  " content="1"/>
    </div>
  {%- endif -%}
</div>

Leave a comment