Advanced widget embedding

Learn how to insert parameters to the embed code to have your widget appear different in different contexts.

Tero Lindeman

Last Update hace un mes

When embedding a widget on a webpage it is possible to give additional parameters that alter the widget appearance. This makes it possible to reuse the same widget to display a different set of reviews with a different title.


Reusing the widget will reduce manual work when embedding widgets on multiple pages to show reviews for different products or locations.

The filter parameters are simply appended after the widget ID in the script embed's URL or in the data-trustmary-widget attribute in the <div> embed. See examples below.


The parameter values have to be encoded in case they contain special characters.

Non-coder instructions

Have more than a dozen review connections or locations? You might want to consider using our API for managing review connections (developers) to automate this for you.

Step-by-step setup for review connections

  1. Add review connections (Google, Booking.com, TripAdvisor, etc.) on the Review Connections page.
  2. Give each review connection a unique short name in advanced settings.

3. Create a widget (or open a pre-existing one).

4. Copy the embed code and add ?connection=[short-name] at the end of it, after the widget ID. 

In this example, the short names are called mono-sushi and nanapo-sushi, so the codes would look like this:

5. Go to your website editor and paste the code with the added short name.

Case example: Sushi Helsinki

Currently, Sushi Helsinki has

  • Dozens of sushi restaurants with unique landing pages
  • Imported Google reviews for each location and given them unique short names
  • One widget was added to multiple landing pages and filtered with review connections

Mono-sushi

Nanapo Sushi

If the site owner wants to update the appearance of widgets, they'll only need to modify one widget in Trustmary. 


Once they save changes in the widget editor, all of the dozens of widgets will automatically be updated without touching the code again.


This was just one simple use case, but let's go over some more in detail.

Changing widget content

It is possible to change the title of the widget and the product name in Schema.org structured data for the widget by using parameters.

Change widget title field

The widget title field used by some widget templates can be overridden with the title parameter. In script embeds the parameter is placed after the URL:

Alternatively, if you are using the div embedding method, the parameter is placed after the data-trustmary-widget variable:

Change the product name field in structured data

If Schema.org structured data is included with the widget it might be useful to set the productName field to reflect the content of the widget. Especially, when listing reviews for a single business location or a product, the productName field should refer to that item instead of the whole company. Use the productName parameter to change the product name in the structured data:

Filtering reviews with parameters

You can also filter reviews into the widget by the review connection, and custom rules (contact and review fields).

Filter by review connection (continued)

As shown in the example above, it is possible to display only reviews that have been imported from a specific review connection (Google, Facebook, Tripadvisor, etc.).


Here are some advanced steps you can take when filtering reviews like this. 


Below you'll see the "basic" form of how to use the connection parameter This will display only reviews that have been imported from the review connection you have given the short name of "my-connection".

Multiple connections can be specified as a comma-separated list:

A wildcard can be used to select all connections with a matching short name. In the below example all review connections with a short name that starts with "helsinki-" are selected:

If you're using the <div> embedding method, the connection parameter would look like this:

Custom rules (contact and survey fields)

Custom rules can be used to filter by contact or survey fields.


Some example use cases:


  • You have multiple business locations and your website has separate subpages for each location. It is possible to use the location as a parameter to display just the reviews for that location.
  • You want to display reviews from a subset of customers that e.g. bought a specific product.


For example, if you want to display reviews for your Helsinki location, and you have collected the survey answers so that the p1 segment is set to the location name, the filter can be set as below:

Available fields for surveys:

  • survey.source: the source URL for a survey as automatically set by the widget
  • survey.p1survey.p20: the segmentation parameters as given as the form URL query parameters
Learn more about segmentation with parameters here.

You can also use the contact's custom fields. If you have stored the customer's primary location as the field LOCATION, you can use the following parameters:

The parameters given will be appended to the rules you might have set in the widget editor. E.g. if you have set a custom filter to display only reviews with five stars, adding a p1 as a parameter will display only reviews with five stars that also have p1 set as the given value.

Available fields for contacts:
  • contact.field_<FIELDNAME>: a custom field as set in contact details.


Learn more about custom fields here.

Still need help? Message Us