How Can We Help?

Why do my scripts appear as text on the website?

Updated April 22, 2024

This usually happens when the script code is not correctly embedded within your Shopify store's HTML. To ensure your scripts run properly and do not show as plain text, you need to wrap them in <script> tags.

Make sure your script is placed within <script> tags. For example, if you are adding Google Tag Manager, your code should look like this:

<!-- Google Tag Manager -->
<script>
  (function(w, d, s, l, i) {
    w[l] = w[l] || [];
    w[l].push({
      'gtm.start': new Date().getTime(),
      event: 'gtm.js'
    });
    var f = d.getElementsByTagName(s)[0],
      j = d.createElement(s),
      dl = l != 'dataLayer' ? '&l=' + l : '';
    j.async = true;
    j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
    f.parentNode.insertBefore(j, f);
  })(window, document, 'script', 'dataLayer', 'GTM-XXXX');
</script>
<!-- End Google Tag Manager -->

After inserting the script, preview your site to ensure everything works as expected. If the script still appears as text, double-check for typos or missing tags.