Stamped aggregate rating & review error

#38390
  • Resolved peeyoosh kumar
    Rank Math pro

    Hello:

    We are using Stamped as review collector on our website along with rankmath suite. When we test the data from Google structure data tools & Rich results are getting error message on “aggregateRating” & “review” fields.

    When i contacted Stamped they shared the attached file to be replaced and the below script to be added to footer. Although i do not want to change the source file of Rankmath plugin as once i upgrade those changes would be lost and it would be a tough task to get it back again up and running.

    1.In this location, please update the class-product.php (attached in this ticket)
    /wp-content/plugins/seo-by-rank-math/includes/modules/rich-snippet/snippets
    2.In WooCommerce footer, please add these JS script:

    <script>
    function addEventListenerStamped(el, eventName, handler) {
    if (el.addEventListener) { el.addEventListener(eventName, handler); }
    else { el.attachEvent('on' + eventName, function () { handler.call(el); }); }
    }
    
    addEventListenerStamped(document, 'stamped:reviews:loaded', function(e) {
    var ratingCount = jQuery('meta[itemprop="reviewCount"]').attr('content');
    var ratingValue = jQuery('meta[itemprop="ratingValue"]').attr('content');
    
    var richSnippet = {
    "@id": location.href + '#product',
    "@context": "http://schema.org",
    "@type": "Product"
    }
    
    if (parseInt(ratingValue) > 0){
    richSnippet.aggregateRating = {
    "@type": "AggregateRating",
    "ratingValue": ratingValue,
    "reviewCount": ratingCount
    }
    }
    var script = document.createElement('script');
    script.type = 'application/ld+json';
    script.innerHTML = JSON.stringify(richSnippet);
    document.getElementsByTagName('head')[0].appendChild(script);
    });
    
    </script>

    Is there some solution Rankmath team can offer so it works out of the box?

    Regards

Viewing 3 replies - 16 through 18 (of 18 total)
  • Hello,

    I updated the code on your site. The product pages are now showing the Stamped ratings.

    I hope that helps.

    peeyoosh kumar
    Rank Math pro

    Hello Pratik:

    Thanks for your time and help. Appreciate it. Although we still see one error and one warning related to schema.

    1.mpn which should be SKU and instead we see it being taking the brand name instead and hence giving error.

    2. review The review field is recommended. Please provide a value if available.

    Any help on these possible?

    Todd
    Rank Math free

    Hi Peeyosh,

    1. For the GTIN, ISBN, MPN issue, you can fix it by adding that to your products using the custom product attribute feature in WooCommere or you can use this plugin: https://wordpress.org/plugins/product-gtin-ean-uc-isbn-for-woocommerce/

    2. Since you are now using Stamped for reviews, you will need to contact them for any Schema mismatch issues.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 16 through 18 (of 18 total)

The ticket ‘Stamped aggregate rating & review error’ is closed to new replies.