Website Code Injection Guide: How to Add Custom HTML and Scripts

By Michael Chen

December 12, 2024 at 04:09 PM

Code injection allows you to enhance your website by adding custom HTML and scripts to specific areas. Here's what you need to know:

Key Locations for Code Injection:

  • Header: Adds code to the
    <head>
    tag on all pages
  • Footer: Injects code before the closing
    </body>
    tag
  • Lock Page: Appears above password fields
  • Order Confirmation Page: Shows after gift card/subscription purchases
  • Order Status Page: Displays after physical/digital product purchases

Important Guidelines:

  • Use code injection for scripts, not content or styles
  • Add JavaScript between
    <script>
    tags
  • Place CSS in the custom CSS editor instead
  • Disable scripts while editing if needed
  • Ajax loading may affect CSS functionality
  • Checkout pages don't support code injection

Page-Specific Injection:

  • Access through Pages panel > Advanced
  • Available for individual pages and blog posts
  • Location varies by template version

Order Tracking Tags:

{orderId}
{orderSubtotal}
{orderSubtotalCents} 
{orderGrandTotal}
{orderGrandTotalCents}
{customerEmailAddress}

Cookie Banner Integration:

  1. Enable cookie banner in settings
  2. Select Accept/Reject options
  3. Add compatible tracking code
  4. Save changes

Migrate order confirmation code

Migrate order confirmation code

Troubleshooting:

  • Disable scripts in preview if editing issues occur
  • Test in incognito window to see custom code
  • Remove problematic code temporarily during troubleshooting
  • Add "/safe" to URL if needed

For custom code development:

  • Follow external customization guidelines
  • Consider hiring a certified expert
  • Visit community forums for support
  • Explore premium plans for advanced features

Related Articles

Previous Articles