​How to add TrustBoxes to your website using Google Tag Manager

Would you like to add a TrustBox widget to your website, but you've got limited access to the source code? Then Google Tag Manager (GTM) might be the right solution for your company.

With GTM, you can add a TrustBox to your website as a custom script. The following article will walk you through how to set up GTM, create a new Custom HTML tag, add the TrustBox code, and finally, position it on the web page. Note that basic knowledge of HTML is required.

Before getting started, you’ll need your TrustBox code. Log into your Trustpilot Business account and select the TrustBox you want to implement > Configure your TrustBox > Click on Get code.

Set up Google Tag Manager

Check that GTM is set up 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.

Create a new Custom HTML tag

Log into your GTM account and create a new Custom HTML tag.

The Google Tag Manager control panel. Choose Custom HTML to add your TrustBox.

Add TrustBox code and position it on the page

If you copy-paste your TrustBox code inside the tag configuration, your widget will by default appear at the bottom of the web page. You’ll need to add some extra lines of code to reposition your TrustBox.

Identify where on the page you want to position the TrustBox

There are two options for repositioning your TrustBox:

Option A

If you have access to the HTML of your page, add a TrustBox placeholder container, e.g., <div id="trustbox"/>. Then inject the TrustBox in the placeholder container via GTM.

Option B

Find an existing container in your HTML source and reference to its ID or class property in GTM to inject the TrustBox.

If your page has an element with an ID called, e.g., “customer-experience” you can reference to it in GTM as the container for your widget.

Position the TrustBox in the selected container

In the Tag configuration panel of GTM, paste your TrustBox’ code wrapped inside a JavaScript function.

Use the following snippet and replace the orange placeholders HTML with the ID or class property of the container you want to position the TrustBox in and the DIV code of your TrustBox:

 (function () {
  var containerId = 'HTML_ID';
  var trustboxContainer =
   document.getElementById(containerId) ||
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.

After you add the code snippets, choose a firing trigger for this tag. You’ll need to select a DOM Ready trigger.

Add a DOM Ready trigger for your new tag in Google Tag Manager.

You should now be able to create a new version in GTM and publish your changes.