Hello! How can we help?

Browse the Trustpilot Support Center to find info on Google Seller Ratings, Rich Snippets, TrustBoxes, Product reviews, plus how-to guides for editing your reviews and account settings

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="https://www.trustpilot.com/review/example.com" 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:

window.Trustpilot.loadFromElement(trustbox);

Comments

0 comments

Please sign in to leave a comment.