BigCommerce Troubleshooting

A script added in Script Manager does not load

A Script Manager script that never runs is usually limited by its location, consent category, theme placeholders or integrity hash; check each and verify in dev tools.

Last updated · Domains, themes and storefronts · Error code: Enter a valid script · Applies to: Stencil and Catalyst storefronts, including Multi-Storefront channels

Symptoms

  • You saved a script in Script Manager, but it never appears in the page source or the browser's Network tab.
  • The script loads on product and category pages but not on checkout, the order confirmation page, the login page or My Account (or the reverse).
  • The script loads for you but not for some shoppers, typically those who declined cookies in the consent banner.
  • The script tag is present, but the browser console reports an integrity (SRI) error and the code never runs.
  • When you save the script, Script Manager shows "Enter a valid script".
  • On a Catalyst storefront, the script runs on the first page view but not after the shopper navigates to another page.

Cause

Script Manager only renders a script where its settings, the theme and the shopper's consent all allow it. The most common causes, most likely first:

  1. Location does not match the page. "Storefront pages" excludes checkout and order confirmation. "Checkout" covers only the checkout page, and "Order Confirmation" only that page. According to the Scripts API documentation, "Storefront pages" also leaves out the Login and My Account pages, which only "All pages" includes.
  2. Consent category blocks it. With the cookie consent banner enabled, scripts in the Analytics, Functional and Targeting/Advertising categories load only when the shopper accepts that category. Only Essential scripts always load.
  3. The theme is missing the placeholder. Stencil templates must output {{head.scripts}} for header scripts and {{footer.scripts}} for footer scripts. If the placeholder for the chosen placement is missing from a layout, the script does not render on pages that use it. Blueprint themes do not render Script Manager scripts at all.
  4. The integrity hash no longer matches. If the hosted file changed after you added the hash, the browser refuses to run it.
  5. Wrong channel or storefront version. Scripts are tied to a channel. On a Multi-Storefront store, a script added to one channel does not appear on another. Catalyst versions before 1.1 do not render scripts.

Resolution

  1. Wait and hard refresh. The Using Script Manager article notes a cache time of 20 seconds for new or changed scripts. Reload with the cache bypassed before changing anything.
  2. Confirm the channel. Open the script from Storefront › Script manager. On a Multi-Storefront store, go to Channels › Channel Manager and use Scripts under Quick links for the channel that serves the page you are testing.
  3. Check Location and Placement. Set Location to match the pages you need. If the script must run on checkout or login, "Storefront pages" will not reach them; choose "Checkout" or "All pages". BigCommerce recommends footer placement for checkout, order confirmation and all-pages scripts.
  4. Check the Script category. Uncategorized scripts default to Essential. If the script is Analytics, Functional or Targeting/Advertising, test with that category accepted in the consent banner. Do not reclassify a tracking script as Essential just to make it load; the categories exist to help you meet privacy laws such as GDPR and CCPA.
  5. Fix the input if the save fails. "Enter a valid script" appears when the code is not wrapped in <script> tags or contains <noscript> tags. Inline scripts are limited to five <script> tags.
  6. Update the integrity hash. For URL scripts, regenerate the SHA-256, SHA-384 or SHA-512 hash for the current file. You can store up to five hashes and remove ones that are no longer valid. Scripts on payment pages such as checkout need at least one hash for PCI DSS compliance.
  7. Check the theme. On a custom or private Stencil theme, search the layout templates for {{head.scripts}} and {{footer.scripts}} and restore any that were removed. Checkout scripts also render only when the store uses Optimized One-Page Checkout, the default for new Stencil stores. API-created scripts do not render when you develop a theme locally with Stencil CLI, so test on the store itself.
  8. On Catalyst, check the version and navigation. Upgrade if you are below 1.1. Catalyst loads scripts deferred through next/script, so they do not fire immediately like a traditional <script> tag and are not guaranteed to fire on every page navigation. Code that must run on every page change needs to handle route changes rather than run once. Catalyst scripts must also contain static content, because Handlebars helpers and theme context variables are not supported. If cookie consent is disabled in store settings, all scripts load immediately. See BigCommerce's Catalyst script guide.
  9. Verify. Open the page in a private window, set the consent state you are testing, then confirm in developer tools that the script tag is in the source, the file loads in the Network tab, the console shows no integrity error, and the script performs its action (for example, a tag fires or a widget appears).

How to prevent it

  • Categorize every script when you add it, and test each one with consent both accepted and declined.
  • Re-check the header and footer placeholders after every theme upgrade or customization.
  • When a vendor updates a hosted file, update its integrity hash at the same time, or the checkout script will stop running.
  • Move entries from the legacy Footer Scripts field into Script Manager so they follow shopper consent.
  • Keep the limits in mind: 50 control panel scripts per channel, and 10 API-created scripts per app.

B2B and multi-storefront notes

Stores that run separate B2B and retail storefronts, or regional channels, need each script added per channel. Authorized control panel users can change the consent category of scripts that apps created through the Scripts API. If an app's storefront feature stops working, check whether its script was moved into a non-essential category before contacting the vendor.

When to get help

If the script appears in Script Manager, the placeholders are present, consent is accepted, and the tag still never reaches the page source, contact BigCommerce support with the script name, channel and a test URL.

More in the BigCommerce knowledge base, including every article on Domains, themes and storefronts.