Adding JSON script tag in Custom Container

Bronze Contributor
Bronze Contributor
Is it possible to add a JSON script tag in a custom container? We're trying to add the improved Google sitelinks search box tag from Google, but it uses type="application/ld+json" in the script tag, and in the template we're not supposed to include the script tag. Any suggestions?

Adding JSON script tag in Custom Container

Employee Emeritus

Hi Jonathan, it is possible if you write your own version of an async script insertion and set it's type attribute to what you described. Our best-practices recommendation of how to insert utag.js would be an example of how to set this attribute:

(function(a, b, c, d) {
a = '//';
b = document; c = 'script'; d = b.createElement(c); d.src=a; d.type = 'text/java' + c; d.async = true;
a = b.getElementsByTagName(c)[0]; a.parentNode.insertBefore(d, a);

That being said custom templates can be tricky to get to work correctly. If you need additional help for your specific use-case please don't hesitate to contact your Account Manager.