Generally, the guide describes three methods for dynamically adding structured data to a site using JS:
Google tag manager Using this method involves six steps:
· Setting up and installing Google Tag Manager on the site. · Adding a custom HTML tag to the container. · Inserting the desired block of structured data into the content of the tag. · Installing the container. · Publishing the container in the GTM interface to add a tag to the site. · Checking how the implementation was realized.
Verify your implementation with the Rich Result Test. Server side rendering
When using server-side rendering, you can add the desired structured data to the visualized output. Please refer to your platform documentation to learn how to generate JSON-LD markup for the type of structured data. All recommendations can be found there. The new manual is currently available in English only.