BLOG

SHORT HILLS DESIGN BLOG

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

Published:  January 12, 2019

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:

YouTube video

<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!

Traffic Projection Summary

Your Website Is Losing Money!

Find out how much ogranic traffic your website should be getting through our Traffic Projection Analysis.
SHOW ME OUR POTENTIAL

Was your websitebuilt correctly?

See the training your competitors are reading. 
Watch the first videos for free.
SHOW ME THE VIDEOS
CONTACT US
(973) 715-9947
© Copyright 2008-2023 - Short Hills Design, LLC - All Rights Reserved
phone-handsetmap-marker linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram