1. SEJ
  2.  ⋅ 
  3. News

Google Publishes Guide for Structured Data with JavaScript

dynamic structured data

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:

  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.

Google recommends using the URL input and advises to not use the code input.

This is Google’s recommendation for testing JavaScript dynamically generated structured data:

“We recommend that you use the URL input instead of the code input because there are JavaScript limitations when using the code input (for example, CORS restrictions).”

Read Google’s new documentation here:

Generate structured data with JavaScript

More Resources

Category News Web Dev SEO
SEJ STAFF Roger Montti Owner - at

I have 25 years hands-on experience in SEO and have kept on  top of the evolution of search every step ...

Google Publishes Guide for Structured Data with JavaScript

Subscribe To Our Newsletter.

Conquer your day with daily search marketing news.