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.
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.
You should have basic knowledge of HTML to use Google Tag Manager.
How to do it
-
In Trustpilot Business, go to Share & promote > Website widgets > All widgets. Select your widget, then click Get code.
-
Log in to your Google Tag Manager account and create a new Custom HTML tag.
-
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.
- If you have access to the HTML of your page, add a TrustBox widget placeholder container, for example,
-
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. -
Under Triggering > Firing Triggers, add a DOM Ready trigger as a firing trigger.
-
Create a new version in GTM and publish your changes.
Previous What are TrustBox widgets?
Up next TrustBox widgets - FAQ