skip to Main Content

Convert LD+JSON Schema to Javascript to use in Google Tag Manager

The Solution to the LD+JSON GTM “schema not showing” Problem

For those of us who were used to pasting LD+JSON schema into a script tag in Google Tag Manager, we awoke one day to find out that this approach no longer worked.  Regardless of the reason why, you can still add your schema markup to GTM, but you have to wrap in in a Javascript function.
Remember, once you have the function, you still have to add it to GTM as a custom html tag.
The video below details how you do it (it’s easy), and below that is the code for you to copy to use:

var data ={
var script = document.createElement('script');
script.type = 'application/ld+json';
script.innerHTML = JSON.stringify( data );

Hat-tip to @simoahava for his advice on the tag manager product forum!

Back To Top