Either "offers", "review", or "aggregateRating" should be specified - Google Error

New Member
6 0 0

Just so happens we are also on warehouse. The way I did it was to detect that a change had occurred to the page and then use that mutation to remove the content. I still don't know why Shopify don't have an option for the reviews app to not output JSON data, but given they don't this the code you want:

 

            {% if reviews_count > 0 %}
              <script>
              var target = document.getElementById('shopify-product-reviews')
              
              var observer = new MutationObserver(function(mutations) {
                $('#shopify-product-reviews [type="application/ld+json"]').remove();
              });

              var config = { attributes: true, childList: true, characterData: true };
              observer.observe(target, config);
              </script>
            {%- endif -%}

 

 

It needs to go in product-template.liquid just before the endif that belongs to if section.settings.enable_reviews.
Where review_count has a few lines earlier been defined as (likely to be a change to the original code in the theme, unless they have updated since we had it):

 

{%- assign reviews_count = product.metafields.spr.reviews | split: '"reviewCount": "' | last | split: '"' | first | plus: 0 -%}

 

 

Hope that helps.

0 Likes
New Member
1 0 0

I follow all steps below but i still see this in my serach console! "aggregateRating" should be specified

Here is my schema which i put in my theme.liquid

<script type="application/ld+json"</script>
<script>
{
"@context": "http://schema.org",
"@type": "Product",
"offers": {
"@type": "Offer",
"availability":"https://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}",
"price": "{{ current_variant.price | divided_by: 100.00 }}",
"priceCurrency": "{{ cart.currency.iso_code }}",
"priceValidUntil": "{{ 'now' | date: '%s' | plus: days_price_valid_until | date: '%Y-%m-%d'}}",
"url": "{{ shop.url }}{{ product.url }}"
},
"brand": {{ product.vendor | json }},
"sku": {{ current_variant.sku | json }},
"name": {{ product.title | json }},
"description": {{ product.description | strip_html | json }},
"category": "",
"url": "{{ shop.url }}{{ product.url }}",
{%- if is_barcode_available and is_valid_gtin_length %}
"{{gtin_option}}": {{ current_variant.barcode | json }},
"productId": {{ current_variant.barcode | json }},
{%- elsif is_barcode_available %}
"mpn": {{ current_variant.barcode | json }},
"productId": {{ current_variant.barcode | json }},
{%- endif -%}
{%- if review_count > 0 -%}
"aggregateRating": {
"@type": "AggregateRating",
"itemReviewed": {{ product.title | json }},
"bestRating": "5",
"worstRating": "1",
"ratingValue": "{{ review_rating }}",
"reviewCount": "{{ review_count }}"
},
{%- endif %}
"image": {
"@type": "ImageObject",
"url": "https:{{ product.featured_media.preview_image | img_url: '1024x1024' }}",
"image": "https:{{ product.featured_media.preview_image | img_url: '1024x1024' }}",
"name": {{ product.title | json }},
"width": 1024,
"height": 1024
}
}
</script>
</head>

 

And i put this code into my product.template.liquid file

{% if section.settings.display_product_reviews or section.settings.show_sold_in %}
<div class="group_item">
{% if section.settings.display_product_reviews %}
<span class="shopify-product-reviews-badge" data-id="{{ product.id }}"></span>
{% if reviews_count > 0 %}
<script>
var target = document.getElementById('shopify-product-reviews')

var observer = new MutationObserver(function(mutations) {
$('#shopify-product-reviews [type="application/ld+json"]').remove();
});

var config = { attributes: true, childList: true, characterData: true };
observer.observe(target, config);
</script>

{%- assign review_rating = false -%}
{% if product.metafields.spr.reviews %}
{% capture review_data %}{{ product.metafields.spr.reviews }}{% endcapture %}

{%- assign rating_keyword = '"ratingValue":' -%}
{%- assign rd_a1 = review_data | split: rating_keyword -%}
{%- assign rd_a2 = rd_a1[1] | split: "," -%}
{%- assign rd_a3 = rd_a2[0] | replace: '"', "" -%}
{%- assign review_rating = rd_a3 | plus: 1 | minus: 1 -%}


{%- assign reviews_count = product.metafields.spr.reviews | split: '"reviewCount": "' | last | split: '"' | first | plus: 0 -%}
{%- assign rd_a1 = review_data | split: count_keyword -%}
{%- assign rd_a2 = rd_a1[1] | split: "," -%}
{%- assign rd_a3 = rd_a2[0] | replace: '"', "" -%}
{%- assign review_count = rd_a3 | plus: 1 | minus: 1 -%}
{% endif %}
</script>

What is the problem in these codes?

0 Likes
New Member
6 0 0

I suspect if you look at the source HTML or Google console for that matter you will see that you have two blocks of JSON data one for the product which contains the review information correctly and one for the reviews without the product data that is incomplete. This I suspect is because the content added by the Shopify review app is still there and I suspect that is because the suggested code I put forward was specific to the theme we are using and includes the ID of a div that is in our theme. If a different theme doesn't have the same ID then it is going to fail to find the DIV, which will mean it can't delete it.

0 Likes
New Member
1 0 0

Hello, can you help me please?

I can't find the file to clear the code.

0 Likes
New Member
1 0 0

@tim ,

Looking through the forum trying to find solutions to multiple issues I am looking to address I was wondering if you hire out custom work.  I can do basic HTML but not in depth for what I'm looking for for the site I'm building for myself: 

https://glassesinthemail.com/

Would you please contact me if interested at vbsunglassshack@gmail.com.  I'm new to the forum and Private Messaging privileges have yet to be unlocked

 

  • I'm looking to hide unavailable product variants instead of simply graying them out.
  • I'm wanting to show multiple images per each variant within a product (I know there's apps for this however I would rather have it permanently coded if possible than use an outside app).
0 Likes
Shopify Partner
408 30 51

@SunglassShack 

Akshay is here as a Shopify Partner. 

Please let me know how can I help you? Also please check your email I have sent you an email for this.

Akshay Vaghasiya

Shopify Expert | Skype: akshayvaghasiya84
 - Like and Mark as an Accepted Solution if my reply helpful
 - Feel free to contact me on akshayvaghasiya84@gmail.com or akshayvaghasiya@lavitastic.com for any queries
 - Want to modify or custom changes on store hire me .
0 Likes
New Member
2 0 0

Hi @Leysam,

 

Are you able to assist with this as its not clear when looking at our files what to do. We have the Shopify Review app.

 

regards

Glen

0 Likes
New Member
2 0 0

Hi @Akshay_V 

 

Encountering the same problem here since I started syncronising with Google:

I've been through this topic and it's not very clear what I should do to get resolve this...

I know all is in dutch, but I think you can tell by the looks of it what it is?

If not let me know...

Schermafbeelding 2021-01-13 om 22.24.20.pngSchermafbeelding 2021-01-13 om 22.24.33.png

 

Schermafbeelding 2021-01-13 om 22.25.57.png

0 Likes
Shopify Partner
20 1 10

Hello @Blis , I can help you, mind sending me an email or message where we can discuss this further?

Leysam | The Shopify Guy  
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - Hire me full time or per hour :)


Email me at edwardwindtalker@gmail.com or add me on Skype: samypogs
0 Likes
New Member
2 0 0

@Leysam what is your email? I'm new to the forum and can't see any options to contact you.

0 Likes