How to use TrustBoxes in single-page applications


To load a TrustBox programmatically in a single-page app, you will need to:

  • Make sure the TrustBox script is inserted in your app
  • Make sure the TrustBox HTML snippet is inserted in your app
  • Add a reference to the TrustBox HTML element in JavaScript. For example, you can add a custom id attribute on the <div>:

<div id="trustbox" class="trustpilot-widget" [ long list of data attributes...]> <a href="" target="_blank">Trustpilot</a> </div>

Then, you can call your reference this way:

var trustbox = document.getElementById('trustbox');

Finally, use the window.Trustpilot.loadFromElement method provided by the TrustBox script to load your TrustBox:



Sort by Date Votes
  • Avatar

    Roman Yavoriv


    Thanks a lot!)

  • Avatar

    Beatrice Carraro


    You're welcome, thanks for the feedback!

  • Avatar



    for anyone reading this and using React, you need to place the HTML tag on the page then within your `componentDidMount`, you place the trustbox and window.Truspilot... script.

    and of course, make sure the tp script has already been loaded within the of your site

    @trustpilot, the directions you provided aren't as clear as they could be. you may want to update this and break it out for react, angular, vanilla JS, etc.

  • Avatar

    Beatrice Carraro


    Hi Ben,

    Thanks for your feedback, we've passed it on to our development team!


Please sign in to leave a comment.