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:
<script> (function(){ var data ={ // INSERT LD+JSON MARKUP HERE }; var script = document.createElement('script'); script.type = 'application/ld+json'; script.innerHTML = JSON.stringify( data ); document.getElementsByTagName('head')[0].appendChild(script); })(document); </script>
Hat-tip to @simoahava for his advice on the tag manager product forum!