Google Tag Manager (edit)

https://searchengineland.com/new-official-google-advice-on-generating-structured-data-with-javascript-332218

New official Google advice on generating structured data with JavaScript

Do you use Google Tag Manager or custom JavaScript with structured data? You will want to read this.

Google has released a new developer document with advice on generating structured data with JavaScript. It offers more direction on this topic, something SEOs have been seeking for a while from Google. Previously, SEOs, and sometimes even Google, cautioned to shy away from using structured data in JavaScript.

Applications. Google said, “There are different ways to generate structured data with JavaScript, but the most common are using Google Tag Manager and custom JavaScript.” Google Tag Manager is a platform that allows you to manage tags on your website without editing the code. Here is Google’s advice on both methods.

Google Tag Manager. Follow the steps below to add structured data via Google Tag Manager.

  1. Set up and install Google Tag Manager on your site.
  2. Add a new Custom HTML tag to the container.
  3. Paste the desired structured data block into the tag content.
  4. Install the container as shown in the Install Google Tag Manager section of your container’s admin menu.
  5. To add the tag to your website, publish your container in the Google Tag Manager interface.
  6. Test your implementation.

Custom JavaScript. You can use JavaScript to generate all of your structured data or use it to add more information to server-side rendered structured data, Google said.

Learn more. We highly recommend you read the full help document over here.

Why we care. For some sites, the only way to add structured data is to use JavaScript. Sometimes using Google Tag Manager can help efficiently manage that structured data. Please use Google’s official advice when implementing structured data through JavaScript.