Custom Code Injection

Custom code injection lets you add your own HTML, CSS, and JavaScript to your landing pages and embedded forms. This is essential for adding tracking pixels, analytics scripts, conversion tracking, custom widgets, and other third-party integrations that are not built into LeadCapture.

Where to Find Custom Code Settings

  1. Open your funnel in the builder.
  2. Click the Publish tab.
  3. Scroll to the Custom Code section.

Custom code is organized into two contexts: Landing Page code and Form Embed code.

Landing Page Code

For funnels hosted on a LeadCapture landing page, you can inject code at three locations:

Injection Point Where It Goes Best For
Head Code Inside the <head> section of the page Analytics scripts (Google Analytics, Facebook Pixel), meta tags, CSS stylesheets
Body Start Code Right after the opening <body> tag No-script fallbacks, tag manager containers
Body End Code Right before the closing </body> tag Chat widgets, conversion pixels, deferred scripts

Form Embed Code

For forms embedded on external websites, custom code can be injected at two locations:

Injection Point Where It Goes Best For
Before Form Above the form container on the page Tracking pixels, introductory content
After Form Below the form container on the page Conversion pixels, disclaimers, follow-up scripts

Note that embedded forms cannot inject code into the parent page's <head> section. If you need head-level scripts for embedded forms, add them directly to your website's page template instead.

Common Use Cases

Google Analytics

Add the Google Analytics tracking script to the Head Code section of your landing page. This tracks page views, user behavior, and conversions.

Facebook Pixel

Add the Facebook Pixel base code to the Head Code section. You can then add a conversion event to the Body End Code that fires when a lead completes the form.

Google Tag Manager

Add the Tag Manager container snippet to the Head Code section, and the no-script fallback to the Body Start Code section.

Custom CSS

Add a <style> block to the Head Code to apply custom CSS rules to your landing page elements.

Chat Widgets

Add chat widget scripts (such as live chat or support tools) to the Body End Code so they load after the page content.

Size Limits and Validation

  • Each code snippet has a maximum size of 50 KB.
  • The total custom code across all injection points cannot exceed 200 KB.
  • Certain patterns are blocked for security reasons, including eval(), new Function(), and document.write().
  • Patterns that could redirect the page or access cookies will trigger a warning, but can still be saved if you acknowledge the warning.

Enable/Disable Toggle

Each context (Landing Page and Form Embed) has an enable/disable toggle. When disabled, none of the code in that context is injected, even if code is present in the fields. This lets you quickly turn custom code on and off without deleting it.

Pro Tips

  • Always test your custom code on a preview before driving live traffic. A broken script can prevent the page from loading correctly.
  • Put tracking scripts in the Head Code and conversion scripts in the Body End Code. This ensures tracking initializes early while conversion code does not block the page.
  • If you are embedding the form on your own site, add tracking pixels directly to your website's page rather than using the embed injection points. This gives you more control and access to the full page <head>.
  • Custom code is not executed in the builder preview for security reasons. You need to view the live page to see your scripts in action.
  • If something breaks after adding custom code, disable the toggle to quickly restore normal behavior while you debug.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.