How to load script tag for checkout pages

Topic summary

Main issue: How to load custom JavaScript on Shopify checkout (API version 2022-07).

Key constraints and clarifications:

  • Script tags added to theme.liquid do not run on checkout. Checkout blocks custom scripts for security, so theme edits or theme app blocks won’t affect checkout.
  • Google Tag Manager (GTM) is blocked on checkout by Content Security Policy (CSP), producing “Refused to load the script” errors (screenshot provided).

Available options:

  • Shopify Plus: Historically could inject code via checkout.liquid, but one commenter notes this will be deprecated in August. Plus stores can use Customer Events/Shopify Pixels for tracking.
  • Non-Plus: Cannot run arbitrary scripts on checkout. Use Shopify’s Pixels/Customer Events framework and build compliant app integrations via Shopify APIs instead of script tags.

Resources shared:

  • Shopify Custom Pixels/Customer Events documentation link was provided and found helpful by one participant.

Status:

  • Consensus that arbitrary scripts (including GTM) cannot load on checkout due to security/CSP. Partial guidance given (use Pixels/Customer Events; Plus checkout.liquid until deprecation), but no universal workaround for non-Plus. Discussion remains partially unresolved.
Summarized with AI on January 8. AI used: gpt-5.

Hey there Muhammed! Your question seems to be a Shopify Script question, could you provide more details about what you’re trying to do on that forum?
https://community.shopify.com/category/scripts
Have a great day,
Daniel.

1 Like