- DarkLight
Installing Rich Snippets on Adobe Commerce 2
- DarkLight
To learn more about Rich Snippets and how they are automatically added to your store, please click here.
Automatic Rich Snippets (JSON-LD injection)
Installing the Yotpo Plugin v. 2.4 and up will automatically inject the Rich Snippets code to your shop.
You can view your Rich Snippets mark-up with Google's Testing Tool and see a separate Product tab that only contains Yotpo's Automatic Mark-up:However, if you don't see valid markup in the Structured Data Testing Tool or if you believe that Rich Snippets are not appearing in the Search Engine Organic Result Pages (SERPs), please contact Yotpo support
Manual markup (microdata)
Enabling Rich Snippets
To enable Rich Snippets (manual markup), do the following:
- In your Yotpo Reviews main menu, go to Meta & Google > Google Rich Snippets.
- Turn on the toggle to activate Google Rich Snippets.
Retrieving aggregate scores
To retrieve the total reviews and average score per product, place the following code according to your existing markup:
If you're using the Yotpo Reviews extension 4.0.0 and above:
<!-- Yotpo's Rich Snippets START -->
<?php
$rs_helper = $this->helper('Yotpo\Reviews\Helper\RichSnippets');
$array = $rs_helper->getRichSnippet($this);
?>
<?php if (isset($array["reviews_count"]) && $array["reviews_count"] != 0 ): ?>
<div style="display:none" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<span itemprop="ratingValue"><?php echo $array["average_score"]; ?></span>
<span itemprop="reviewCount"><?php echo $array["reviews_count"]; ?></span>
</div>
<?php endif; ?>
<!-- Yotpo's Rich Snippets END -->
If you're using a previous version of the Yotpo extension:
<!-- Yotpo's Rich Snippets START -->
<?php
$rs_helper = $this->helper('Yotpo\Yotpo\Helper\RichSnippets');
$array = $rs_helper->getRichSnippet($this);
?>
<?php if (isset($array["reviews_count"]) && $array["reviews_count"] != 0 ): ?>
<div style="display:none" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<span itemprop="ratingValue"><?php echo $array["average_score"]; ?></span>
<span itemprop="reviewCount"><?php echo $array["reviews_count"]; ?></span>
</div>
<?php endif; ?>
<!-- Yotpo's Rich Snippets END -->
Example:
<?php $array = $this->helper('yotpo/richSnippets')->getRichSnippet($this); ?>
<?php if ($array["reviews_count"] != 0 ): ?>
<div style="display:none" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<span itemprop="ratingValue"><?php echo $array["average_score"]; ?></span>
<span itemprop="reviewCount"><?php echo $array["reviews_count"]; ?></span>
</div>
<?php endif; ?>
After this code is added to the product page template and the product page is loaded/viewed for the first time, a record will be created in the Adobe Commerce database for the specific product.
Product markup
If you need assistance with manual markup, please refer to these resources:
The mandatory properties in the markup language and the way they should be nested is as follows:
itemscope itemtype="http://schema.org/Product"
| itemprop="name"
| itemprop="offers" itemscope itemtype="http://schema.org/Offer"
| ++ itemprop="price"
| ++ itemprop="priceCurrency"
| itemprop="aggregateRating" itemscope
itemtype="http://schema.org/AggregateRating"
| ++ itemprop="ratingValue"
| ++ itemprop="reviewCount"
Manual markup Rich Snippets troubleshooting
When you install the plug-in, Yotpo creates a table named yotpo_rich_snippets. This table holds your products' aggregate rating data used by Google's Rich Snippets. If you are using a DB prefix for your store, this table should be created with the same prefix.
If you're having trouble with the rich snippets functionality, verify that the table was created correctly and that it holds valid values in the average_score and reviews_count columns. If this is not the case, please contact Yotpo Support.
Validation
Test the markup on Google Structured Data Testing Tool. The result should look like this:
Google Crawling
If you have marked up your page correctly and it shows the stars in the Google testing tool, keep in mind that you will need to wait approximately 24 hours for it to be indexed by Google. The waiting time depends on Google.
Google makes algorithmic determinations on when and how to display results in the SERPS (search engine results page), including snippet information, based on a myriad of factors including the search terms, etc. Even if they are coded correctly, snippet inclusion in the SERPS is beyond Yotpo's direct control.
We would recommend focusing your efforts on making as unique and compelling a site as possible in order to increase the likelihood of your products reviews displaying in the Google search.
Manipulating or changing your aggregateRating markup may lead to Google penalizing your Rich Snippets results.