Add Google trust badge to Magento

Add Google trust badge to Magento

August 15, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Add Google trust badge to Magento

How to Add Google Trust Badge to Your Magento Store: A Step-by-Step Guide

Adding the Google Trusted Store badge to your Magento store is an excellent way to build consumer trust and enhance your brand image. In this guide, we’ll walk you through the process of integrating the Google Trusted Store script into your Magento site smoothly.

Understanding the Google Trust Badge Script

The provided code snippet contains two main sections: one for the Google Trusted Store script and another for the Trusted Stores Order data. The first section loads the Google Trusted Store JavaScript file, which is responsible for displaying the trust badge on your store’s product pages and checkout page.

The second section defines an HTML div that serves as a container for order-specific data. This information includes details like the customer’s email address, the total order amount, shipping costs, tax amounts, estimated shipping date, and item-specific details for each ordered product.

Adding Google Trust Badge to Magento: The Right Approach

Method 1: Using the Magento 2 Theme Layout XML File

The most recommended approach is to add the script to your theme’s layout XML file. This way, you can ensure that the trust badge appears consistently across all pages that use the specified layout handles.

To do this:

  1. Navigate to app/design/frontend/{vendor}/{theme}/Magento_Theme/templates/html/head.phtml.
  2. Add the script tags inside the <head> section of the file:
<referenceContainer name="head.additional">
    <block class="Magento\Framework\View\Element\Template" template="Magento_Theme::html/head.phtml"/>
</referenceContainer>
  1. Open the app/design/frontend/{vendor}/{theme}/Magento_Theme/templates/html/head.phtml file.
  2. Paste the provided Google Trusted Store script inside the <body> tags.

Method 2: Using a Custom Magento Extension

If you prefer to keep your theme files clean, you can create a custom Magento extension to handle the integration of the Google Trust Badge script. This approach allows for better maintainability and easier updates in the future.

Implementing the Trusted Stores Order Data

To provide the required order data to the Google Trusted Store script, you’ll need to update your checkout success page or order confirmation email templates:

  1. For the checkout success page (Onepagecheckout/success.phtml):
<div id="gts-order" style="display:none;">
    <span id="gts-o-id"><?= $order->getIncrementId() ?></span>
    <span id="gts-o-domain"><?= $_SERVER['HTTP_HOST'] ?></span>
    <span id="gts-o-email"><?= $order->getCustomerEmail() ?></span>
    <span id="gts-o-country"><?= $order->getCountryId() ?></span>
    <span id="gts-o-currency"><?= $order->getCurrencyCode() ?></span>
    <!-- Add other required order data fields -->
</div>
  1. For the order confirmation email template (sales_order_template_pdf_invoice.html):
<referenceContainer name="head.additional">
    <block class="Magento\Framework\View\Element\Template" template="Magento_Theme::html/head.phtml"/>
</referenceContainer>

Remember to replace <!-- Add other required order data fields --> with the appropriate values based on your Magento setup.

Testing and Verifying the Integration

After adding the script to your theme or creating a custom extension:

  1. Clear your browser cache and reload your store’s product pages and checkout page.
  2. Verify that the Google Trusted Store badge appears where you expect it to.
  3. Place a test order and check if the gts-order div contains the correct data.

Conclusion

Integrating the Google Trust Badge into your Magento store is a straightforward process once you understand how to add the script to your theme or create a custom extension. This guide demonstrates two methods for adding the trust badge to your site, ensuring that you can choose the approach that best fits your specific needs and preferences.

Don’t forget to test your implementation thoroughly after making any changes to ensure optimal performance and customer experience.

For more advanced Magento development tips and tutorials, be sure to visit Laravel Company for comprehensive guides on Magento 2 themes, layouts, and extension development.

Magento 2 Checkout Catalog Themes

Our network