Pure vanilla JS Trustpilot integration
$ npm install --save-dev @beyonk/svelte-trustpilot
<Trustpilot businessUnit="12345" domain="www.example.com" />
<script>
import Trustpilot from '@beyonk/svelte-trustpilot'
</script>
The attributes you pass to the Trusilot component are listed below, but you need domain
and businessUnit
at a minimum.
<div id="trustpilot-wrapper"></div>
<script>
import Trustpilot from '@beyonk/svelte-trustpilot'
const trustpilot = new Trustpilot({
target: document.querySelector('#trustpilot-wrapper'),
data: {
businessUnit: '12345',
domain: 'www.example.com'
}
})
</script>
There are a number of configuration attributes you can pass, but all are optional.
List of possible options in the module:
Option | Default | Required | Description |
---|---|---|---|
widget (1) | micro-star | false | Widget type as per [https://businessapp.b2b.trustpilot.com/?locale=en-US#/integrations/trustbox/library](Trustpilot Trustbox library) |
domain | - | true | Sets the domain/product name on Trustpilot (for the link when a user clicks your widget) |
businessUnit | - | true | Sets data-businessunit-id as per docs |
width | 100% | false | Sets data-style-width as per docs |
height | 500px | false | Sets data-style-height as per docs |
theme | dark | false | Sets data-theme as per Trustpilot docs |
lib | package-name | false | Unique id to determine if component is loaded. You probably don't need to change this. |
version | v5 | false | Trustpilot SDK version (best not to change) |
* (2) | - | false | Pass any other parameter you want here. See below. |
https://businessapp.b2b.trustpilot.com/?locale=en-US#/integrations/trustbox/configuration/<widget-id-is-here>
data-
attribute you normally pass to Trustpilot's widgets. These will be passed verbatim to the underlying widget HTML.