Knowledge Base

Knowledge base

Explore How-To's and learn best practices from our knowledge base.

Automatic Rich Snippets

Modified on: Sun, 27 Oct, 2019 at 5:55 PM


Automatic Rich Snippets

Judge.me automatically adds rich snippets to all review widgets with at least one review, also on the free plan.

This article covers all the steps you can take to ensure your snippets get indexed by Google and shown in the Google search results.

Upgrade to schema.org/AggregateRating snippets (1 click)

If you've been using Judge.me since before March 2017, it is possible you are still using the old "data-vocabulary" snippets. If that is the case, you will see this notice in the app settings under the SEO tab:

Unless your snippets are currently showing in Google, we recommend you to upgrade to the newer schema.org/AggregateRating snippets. Simply click on "Upgrade To The Latest Rich Snippets" and Judge.me does the rest.

After upgrading your snippets, this is the only rich snippets settings box you will see in the SEO tab of the app settings:

Link all your Product snippets via @id (1 line of code, optional)

This part is only relevant if your theme already has JSON-LD snippets in the product.liquid template. (See example JSON-LD snippets below. Ask your theme developer when in doubt.) Even if so, this part is still not necessary - it's recommended, but optional.

With the upgraded JSON-LD snippets, Judge.me adds Product snippets as well to make sure Google knows our AggregateRating snippets belong to the product on the product page.

Here are the Product snippets Judge.me adds:

As you can see in the screenshot, however, our Product snippets are not linked to the theme's Product snippets by default.

To maximize the chances Google understands all Product snippets belong together, it is best to link the Product snippets as follows:

As you can see in the screenshot above, the two Product snippets (Judge.me's + from the theme) are integrated into 1 Product / Product snippet, because they share the same @id with as value the product URL.

To achieve this result, add this @id line to your theme's JSON-LD Product snippets:

"@id": {{ canonical_url | append: '#product' | json }},

You are most likely to find these JSON-LD snippets added as a script in your product.liquid template. Here is an example of a complete script tag that would cover your theme's JSON-LD Product snippets, with the @id line added below @type:

{% capture jsonld_brand_url %}https://{{ shop.domain }}{{ product.vendor | url_for_vendor }}{% endcapture %}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Product",

  "@id": {{ canonical_url | append: '#product' | json }},

  "brand": {
    "@type": "Brand",
    "name": {{ product.vendor | json }},
    "url": {{ jsonld_brand_url | json }}
  },
  "sku": {{ product.selected_or_first_available_variant.sku | json }},
  "description": {{ product.description | strip_html | json }},
  "url": {{ canonical_url | json }},
  "name": {{ product.title | json }},
  {% if product.featured_image %}
  "image": "https:{{ product.featured_image | product_img_url: 'grande' }}",
  {% endif %}
  "offers": [{% for variant in product.variants %}{
    "@type": "Offer",
    "price": "{{ variant.price | divided_by: 100.0 }}",
    "priceCurrency": "{{ shop.currency }}",{% unless shop.metafields.jsonld.itemCondition == blank %}
    "itemCondition": "http://schema.org/{{ shop.metafields.jsonld.itemCondition }}",{% endunless %}
    "availability": "{% if variant.available %}InStock{% else %}OutOfStock{% endif %}"
  }{% unless forloop.last %},{% endunless %}{% endfor %}]
}
</script>

Let Google re-crawl your rich snippets

It's a good idea to let Google re-crawl your product pages after updating your snippets. More information on how to ask Google for a re-crawl can be found here.

Using Microdata Snippets

If your store does not use JSON-LD snippets then that is completely fine. We also push Microdata snippets, which comes in almost every theme, except a few very old themes which still use data-vocabulary.

Compared to JSON-LD snippets, linking our AggregateRating to the already existing Microdata product snippets has to be done by placing the widget inside the div containing itemscope itemtype="http://schema.org/Product".

If the position you place the widget is out of that div then the AggregateRating will not be linked to the Products rich snippets and thus most likely will be ignored by Google.

To find out if the widget is correctly placed inside the itemscope, all you'll have to do is inspect our widget, find the div with the product itemscope hover over it, then the highlighted section must include our widget as well. Like in the following image:

Disabling JSON-LD snippets

This is not recommended, but if you only want the microdata (HTML) snippets you can disable the Judge.me JSON-LD (Javascript) snippets by putting the following code at the bottom of your product.liquid file:

<script>  judgemeOpts=window.judgemeOpts||{};judgemeOpts.jldDisable=true </script>

Disabling microdata snippets

Microdata standard does not allow for multiple markup in the same Product rich snippet. So if for any reason you want to display two or more review widgets on the same page only one of them should have microdata aggregateRating snippet. To disable microdata snippet please use the following

{% capture review_widget %}  {% include 'judgeme_widgets', widget_type: 'judgeme_review_widget', concierge_install: true %} {% endcapture %}      {{ review_widget | replace: "itemprop", 'duplicated-itemprop' | replace: "itemscope", 'duplicated-itemscope' }}


Remove Duplicated AggregateRating in Woocommerce


Sometimes the markup generated by Woocommerce can cause a duplicated AggregateRating on the product pages. Here's a fix of it, a contribution of Fluidcart.io


Option 1, adding the code in functions.php:

/**
 * Remove WooCommerce Product Schema markup for `aggregateRating`.
 */
function prefix_remove_woocommerce_aggregate_rating_markup( $markup, $product ) {
  unset( $markup['aggregateRating'] );
  return $markup;
}
// IMPORTANT: Should run before YoastSEO WooCommerce filter with priority = 10
add_filter( 'woocommerce_structured_data_product', 'prefix_remove_woocommerce_aggregate_rating_markup', 5, 2 );


Option 2, installing and using the plugin (download here):

<?php
/*
Plugin Name: WooCommerce Schema Fix
Plugin URI: 
Description: Fix conflict between WooCommerce and Judge.me product schema data for `aggregateRating`.
Text Domain: wpseo-woocommerce-gutenberg-fix
Version: 1.0.0
Author: fluidcart.io
Author URI: https://fluidcart.io/
License: GPLv2

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

*/

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) { 
    exit;
}



/**
 * Plugin Main Class.
 */
class WooCommerceSchemaFix {

    // A single instance of this class.
    public static $instances   = array();
    public static $this_plugin = null;



    /**
     * Singleton instance function.
     *
     * @access public
     * @static
     * @return void
     */
    public static function instance() {
        $calledClass = get_called_class();

        if ( self::$instances[ $calledClass ] === null ){
            self::$instances[ $calledClass ] = new $calledClass();
        }

        return self::$instances[ $calledClass ];
    }



    /**
     * __construct function.
     * @access public
     * @return void
     */
    public function __construct() {
        $this->hooks();
    }



    /**
   * Initialize hooks.
   */
    public function hooks() {
        // IMPORTANT: Should run before YoastSEO WooCommerce filter with priority = 10
        add_filter( 'woocommerce_structured_data_product', array( $this, 'remove_woocommerce_aggregate_rating_markup' ), 5, 2 );
    }



    /**
     * Remove WooCommerce Product Schema markup for `aggregateRating`.
     */
    public function remove_woocommerce_aggregate_rating_markup( $markup, $product ) {
        unset( $markup['aggregateRating'] );
        return $markup;
    }


}

WooCommerceSchemaFix::instance();



Tips or remarks?

If you followed a different approach than we offer to get your review snippets indexed by Google, please email us at support@judge.me so we can discuss.

Judge.me considers rich snippets a super core feature so we will dedicate priority developer time to improve our rich snippets whenever needed.



Did you find it helpful? Yes No Still have questions? Talk to us here

Can you please tell us how we can improve this article?

More articles in SEO