How To Display Trustpilot Product Reviews On Shopify

As any eCommerce store owner will know, reviews are an essential tool to turn website visitors into customers and there’s no better way to do this than displaying specific reviews against each product on your store.

Trustpilot aim to make this as easy as possible by providing a selection of widgets which you can swiftly embed on to a website. Simply enter the SKU number for the product, add the source code to your website and the widget will show customers all of the reviews for that product.

For some Shopify ecommerce store owners however, this doesn’t provide a complete solution.

Displaying Reviews for Products With One SKU Number

As with most online eCommerce platforms, the pages that make up the store are dynamically created from a template file. Each template contains snippets of code that change certain features on the page, such as Product Name, Product Price, etc.

Entering a SKU number into the Trustpilot widget code would only display reviews for that specific product, which isn’t ideal on Shopify as for that to work you would need to create a unique template for each product.

Fortunately, there is also a snippet of code we can use which looks up the product’s SKU number, which is {{ variant.sku }}. If you replace the SKU field in the Trustpilot widget code with this, the widget will now display the reviews for that specific product.

The full Widget code will look something like this:

<!-- TrustBox widget - Product Reviews -->

<div class="trustpilot-widget" data-locale="en-GB" data-template-id="544a426205dc0a09088833c6" data-businessunit-id="xxxxxxxxxxxxxxxxxxxx2b23" data-style-height="700px" data-style-width="100%" data-theme="light" data-sku="{{ variant.sku }}">

<a href="https://uk.trustpilot.com/review/firstmats.co.uk" target="_blank" rel="noopener">Trustpilot</a>

</div>

<!-- End TrustBox widget -->

To use this code, go to the Theme editor and paste the code above into your “product.liquid” template file. You’ll need to paste it where you want it to appear on the page, which is usually under the product description.

Displaying Reviews for Products With Multiple SKU Numbers

Whilst the code above will work perfectly for products that use a single SKU number, Shopify store owners with more than one SKU per product will need a different solution. This is because the code above will only use the SKU number of the default variant, so only reviews for that variant will appear.

What we need to do is adjust the widget code so that rather than listing a single SKU number, it lists all of them.

Trustpilot supports products with multiple SKUs by allowing several SKU numbers to be placed into the widget and separated by a Comma, so the new code will follow this format.

We will use most of the same code, but changing the SKU field to;

{{ product.handle}}ALL,{{ product.variants | map: 'sku' | join: "," }}

This code, translated into English, looks for all variants associated with a handle (that’s the last part of the web address) and then lists the SKU numbers, joined together with a comma.

So added to the Widget code, it will look like this:

<!-- TrustBox widget - Product Reviews -->

<div class="trustpilot-widget" data-locale="en-GB" data-template-id="544a426205dc0a09088833c6" data-businessunit-id="xxxxxxxxxxxxxxxxxxxx2b23" data-style-height="700px" data-style-width="100%" data-theme="light" data-sku="{{ product.handle}}ALL,{{ product.variants | map: 'sku' | join: "," }}">

<a href="https://uk.trustpilot.com/review/firstmats.co.uk" target="_blank" rel="noopener">Trustpilot</a>

</div>

<!-- End TrustBox widget -->

Paste the code above into your product.liquid template and the Trustpilot Widget will now display all of the reviews for all of the variants on that product page.

Was this post helpful?

0 comments

Sort by
Please sign in to leave a comment.