Use Google Tag Manager to add a TrustBox to your website

When you want to add a TrustBox to your website but have limited access to the source code, use Google Tag Manager (GTM) to add the widget as a custom script.

With GTM, you add a TrustBox to your website as a custom script. You'll use GTM to create a new Custom HTML tag, add the TrustBox code, and finally, 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 TrustBoxes. If you need help, please refer to Google’s GTM support article.

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

Add a TrustBox to your website using Google Tag Manager

  1. In Trustpilot Business > Showcase, find your TrustBox widget, and click the Get Code button.
  2. Log in to your Google Tag Manager account and create a new Custom HTML tag.
  3. Your widget appears at the bottom of the page by default. There are two ways to move the TrustBox to another location:
    • If you have access to the HTML of your page, add a TrustBox placeholder container, for example, <div id="trustbox"/>. Use GTM to inject the TrustBox in the placeholder container.
    • Find an existing container in your HTML source and refer to its ID or class property in GTM to inject the TrustBox. In the example below, you'd refer to the "customer-experience" element as your widget's container in GTM.
  4. In the Tag Configuration panel, paste the TrustBox 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 TrustBox code from the Trustpilot Business app. 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.
  6. Create a new version in GTM and publish your changes.