Add a TrustBox widget using Google Tag Manager

This feature is included in the Free plan

Get started now

If you want to add a TrustBox widget to your website but have limited access to the source code, you can use Google Tag Manager (GTM) to add the widget as a custom script. This guide shows you how to do it.

GTM allows you to add a widget to your website as a custom script. You'll use GTM to create a new Custom HTML tag, add the widget's code, then position it on the web page.

Check that you've set up GTM correctly on all the web pages where you’d like to display widgets. If you need help, refer to Google’s GTM support article.

Note: You should have basic knowledge of HTML to use Google Tag Manager.

How to do it 

  1. In Trustpilot Business, go to Showcase > Website widgetsSelect your widget, then click Get code
  2. Log in to your Google Tag Manager account and create a new Custom HTML tag.
    Google Tag Manager's platform highlighting Custom HTML to select
  3. Your widget appears at the bottom of the page by default. There are two ways to change its placement: 
    • If you have access to the HTML of your page, add a TrustBox widget placeholder container, for example, <div id="trustboxwidget"/>. Use GTM to insert the widget in the placeholder container.
    • Find an existing container in your HTML source and refer to its ID or class property in GTM to insert the widget. In the example below, you'd refer to the "customer-experience" element as your widget's container in GTM. HTML code example for existing container
  4. In the Tag Configuration panel, paste the widget's code and wrap it inside a JavaScript function.
    • Replace the HTML_ID placeholder with the ID of the container you chose in step 3.
    • Replace the TRUSTBOX_HTML placeholder with the widget's HTML code. It's the code with the <div> element.
    <script>
     (function () {
      var containerId = 'HTML_ID';
      var trustboxContainer =
       document.getElementById(containerId) ||
       document.getElementsByClassName(containerId)[0];
      if (trustboxContainer) {
       var trustbox = document.createElement("div");
       trustbox.innerHTML = 'TRUSTBOX_HTML';
       trustboxContainer.appendChild(trustbox);
      }
     })();
    </script>
    <!-- TrustBox script -->
    <script type="text/javascript" 
    src="//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js" async></script>
    <!-- End Trustbox script -->
    	
    Important: Always add the bootstrap script right after the HTML code.
  5. Under Triggering > Firing Triggers, add a DOM Ready trigger as a firing trigger. Google Tag Manager platform for adding a DOM ready trigger as a firing trigger
  6. Create a new version in GTM and publish your changes.

Previous Introduction to TrustBox widgets

Up next TrustBox widgets - FAQ