Website Code Injection: How to Add Custom HTML and Scripts to Your Site

By Michael Turner

December 12, 2024 at 01:36 PM

Code Injection Guide

Use code injection to enhance your site with custom HTML and scripts for features like live chat, domain verification, or analytics.

Important Notes:

  • Code injection is for HTML/scripts only, not for content or styles
  • For styles, use the Custom CSS Editor instead
  • Some features may need to be disabled during site editing
  • Surround JavaScript with
    <script></script>
    tags
  • Surround CSS with
    <style></style>
    tags
  • Checkout pages don't support code injection

Main Injection Points:

  1. Header
  • Injects into
    <head>
    tag on all pages
  • Best for meta tags and tracking scripts
  1. Footer
  • Injects before closing
    </body>
    tag
  • Ideal for third-party integrations
  1. Lock Page
  • Appears above password field on locked pages
  • Recommended: Use Lock Screen panel instead
  1. Order Confirmation Page
  • Displays after gift cards/memberships purchases
  • Supports customer-specific tags:
    • {orderId}
    • {orderSubtotal}
    • {orderSubtotalCents}
    • {orderGrandTotal}
    • {orderGrandTotalCents}
    • {customerEmailAddress}
  1. Order Status Page
  • Shows after physical/digital product purchases
  • Supports same tags as confirmation page
  • Use
    {.if firstPageView}
    for single-run scripts

Adding Code:

  1. Open Code Injection panel
  2. Insert valid HTML/scripts in appropriate fields
  3. Click Save

Cookie Banner Integration:

  1. Enable cookie banner in Cookies & Visitor Data panel
  2. Select "Opt in & out" type
  3. Add integration code
  4. Save changes

Gray box with custom Instagram link

Gray box with custom Instagram link

Per-Page Injection:

  • Access through page settings (⚙️ icon)
  • Available for individual pages and blog posts
  • Varies by site version

Troubleshooting:

  • Use "Disable Scripts in Preview" when editing
  • Test custom code in incognito/private window
  • Remove problematic code temporarily if issues persist
  • Follow best practices for custom code implementation

Remember to always test your injected code thoroughly and keep backups of your modifications.

Related Articles

Previous Articles