Search code examples
google-tag-managerschema.orgjson-ld

GTM Not Writing to Page With Custom HTML Tag


I'm trying to implement schema markup on my site using Custom HTML tags in Google Tag Manager. When I preview my changes, it works perfectly. However, when I push the tag live, it does not appear on my page.

I've had a similar issue with tags in preview appearing differently than in live. But when I tried looking into it, it I couldn't find an answer on why that would happen.

So I'm wondering if you have any insights into why this tag works in preview, but does not work live?

HTML

Tag


Solution

  • I figured it out. We had an X-XSS-Protection header set to 1;mode=block which was limiting Google Analytics from injecting scripts that could be considered an XSS attack.

    This could have also happened with an incorrectly configured Content-Security-Policy.

    The correct way to set up a Content-Security-Policy that allows Google Analytics and Google Tag Manager to inject scripts is outlined in this Lunametrics article (take note of Simo Ahava's comment after the post).