How to show your stars in the organic search engine results on Google.

About Rich Snippets

Snippets showing your reviews under a search result are designed to give users more information about this page and why it’s relevant to their query. This is a very attractive way to draw attention to your offers:

Trusted Shops RichSnippets Example

In order to add your stars as a review snippet to your shops listings in the organic search engine results on Google, some extra lines of structured data markup have to be embedded to your website. Your current rating and number of reviews within this markup can be retrieved using the Trusted Shops API.

With your reviews prepared like this, Google crawler can fetch the data automatically while visiting your website.
Please note that even with the correct integration of a valid markup, Google does not guarantee that the stars and grade will be displayed on search results pages.

Following Google’s guidelines, it is not recommended to embed rich snippets on your home page. Instead, product and category pages, as well as an extra content page, will be the right places.

For more information on Google’s rich snippets we suggest the following reading:

Example Implementation

The PHP code below implements a call to the Trusted Shops API to retrieve the current grade and number of reviews.
A caching routine saves the data locally, so no unnecessary API calls have to be made.
Finally, a markup according to the guidelines above is generated.

To verify a successful implementation, please use Rich Snippets Testing Tools.

This is an example of integrating Trusted Shops Customer Reviews
marked with structured data into your website
Make sure you replace value of $tsid with your Trusted Shops ID
Make sure you have a writing permission to the
folder set in $cacheFileName
Requires version PHP 5.+
$cacheFileName '/tmp/' $tsId '.json';
$cacheTimeOut 43200// half a day
$apiUrl '' $tsId '/quality/reviews.json';
$reviewsFound false;

if (!
function_exists('trustedshopscachecheck')) {
trustedshopscachecheck($filename_cache$timeout 10800) {
        if (
file_exists($filename_cache) && time() - filemtime($filename_cache) < $timeout) {

// check if cached version exists
if (!trustedshopscachecheck($cacheFileName$cacheTimeOut)) {
// load fresh from API 
$ch curl_init(); 
$output curl_exec($ch); curl_close($ch); 
// Write the contents back to the file 
    // Make sure you can write to file's destination 
if (
$jsonObject json_decode(file_get_contents($cacheFileName), true)) {
$result $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['overallMark'];
$count $jsonObject['response']['data'] ['shop']['qualityIndicators']['reviewIndicator']['activeReviewCount'];
$shopName $jsonObject['response']['data']['shop']['name'];
$max "5.00";
    if (
$count 0) {
$reviewsFound true;
if (
$reviewsFound) {
// Output aggregated reviews markup:    
    <div itemscope itemtype="">
        <div itemprop="aggregateRating" itemscope itemtype="">
            <meta itemprop="name" content="">
            <span itemprop="ratingValue"><?php echo $result;?></span> /
            <span itemprop="bestRating"><?php echo $max;?></span> of
            <span itemprop="ratingCount"><?php echo $count;?> </span>
            <a href="<?php echo $tsId?>.html" title="<?php echo $shopName;?> custom reviews" target="_blank"><?php echo $shopName;?> customer reviews | Trusted Shops</a>
<?php }


Please note that caching of API calls is essential. Without caching your website, it will be directly affected in case of a downtime of the API or poor network performance.

As data like overall mark and number of reviews returned by the Trusted Shops API are calculated on a daily basis, it is sufficient to update your cache once or twice a day.

Please note that Trusted Shops may limit the number of API calls per day and website without notice.