Close

Google Publishes Guide for Structured Data with JavaScript

Google published a new developer page for generating structured data with JavaScript. The guide provides guidance on how to do it properly so that it wins in Google search.

The new guide states that there are two ways to generate structured data using JavaScript.

Google’s Martin Splitt announced Google’s new JavaScript structured data guidelines on LinkedIn

martin splitt linkedin structured data with javascript announcement

The developer page discusses three ways to generate structured data with JavaScript

  1. Google Tag Manager
  2. Custom JavaScript
  3. Server Side Rendering

JavaScript plays an increasing role in how sites are developed. Guidance on how to dynamically generate structured data using JavaScript is going to be immensely helpful.

Google Tag Manager (GTM)

Google lists six steps for generating structured data dynamically with GTM:

  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

Google lists three steps for developing JavaScript structured data with custom JavaScript

  1. Find the type of structured data you are interested in.
  2. Edit your website’s HTML to include a JavaScript snippet like the example below (refer to the documentation from your CMS or hosting provider, or ask your developers).
  3. Test With the Rich Results Test

The Google documentation only says to test it with the Rich Results Test probably because it does two things at once:

The Future of SEO: How to Safeguard Your Brand in an Unpredictable World
Join Conductor’s virtual event on May 12th to hear from Conductor leaders on the future of search and the SEO strategies to protect your business.

  1. Tests for eligibility for rich results
  2. Checks if the structured data validates

Google also has the Structured Data Testing Tool that tests if the structured data is valid but doesn’t give feedback about rich results.

The Rich Results testing tool does double duty by showing warnings and errors in addition to showing if the structured data is eligible for rich results.

There are two ways to test structured data in Google’s Rich Results Test. The first way is by entering a URL so that Google crawls the page and extracts the structured data and tests it.

The second way is to input the code directly.