WordPress.org

Plugin Directory

Header Footer Script Adder – Insert Code in Header, Body & Footer

Header Footer Script Adder – Insert Code in Header, Body & Footer

描述

Header Footer Script Adder is a lightweight, highly secure, and performance-optimized WordPress plugin that lets you easily insert custom HTML, CSS, and JavaScript into your site’s header, body, or footer without editing theme files.

Stop modifying your theme’s header.php or footer.php files directly! When you change or update your theme, your crucial marketing, analytics, and tracking codes remain safely stored and active.

The Free Version gives you immediate, bloat-free global text areas to inject your scripts across your site, while the Pro Version unlocks a complete, developer-grade Tag Management System to control exactly how, when, and for whom your scripts execute.

✨ Free Core Features

  • Targeted Placements: Add scripts precisely to the Header (<head>), Body (immediately after <body> via wp_body_open), or Footer (before </body>).
  • Smart Conditional Loading: Control script visibility sitewide, homepage only, posts/pages only, or archive pages.
  • Per-Page & Per-Post Overrides: Inject completely unique tracking codes or custom scripts into specific individual posts or pages.
  • Developer-Grade Code Editor: Built-in CodeMirror code editor with full syntax highlighting for error-free coding.
  • Secure Input Handling: Robust input sanitization without breaking valid HTML, CSS, or JS scripts.
  • Lightweight & Fast: Zero bloat architecture that minimizes database queries to protect front-end site speed.
  • Full Compatibility: Works seamlessly with the Block Editor (Gutenberg), Classic Editor, and WordPress Multisite installations.

✅ Perfect For

  • Analytics & SEO: Google Analytics / GA4 tracking code, Google Tag Manager (GTM), and SEO verification meta tags (Google Search Console, Bing, Pinterest).
  • Conversion Tracking: Meta (Facebook) Pixel, TikTok Pixel, Pinterest Tag, and ad tracking scripts.
  • User Engagement: Live chat widgets (WhatsApp, Crisp, Tawk.to, HubSpot).
  • Custom Styling & Scripts: Global or page-specific custom CSS modifications and JavaScript actions.

🚀 Upgrade to Pro: Unlock Ultimate Control & Speed

For advanced developers, agencies, and e-commerce stores, the Pro version transforms your setup into an advanced tracking engine:

  • 1. Granular Conditional Targeting:

    • User Role Targeting: Load scripts for Everyone, Logged-In Users Only, Logged-Out Users Only, or specific roles (Administrator, Subscriber, WooCommerce Customer, etc.).
    • Device Targeting: Optimize layouts by choosing to load scripts only on Desktop, Tablet, or Mobile devices.
    • Advanced Page-Specific Targeting: Target specific Custom Post Types or key WooCommerce Pages (Shop, Cart, Checkout, Single Products) to eliminate checkout tracking discrepancies.
  • 2. Core Web Vitals & Performance Optimization:

    • Loading Strategies: Automatically inject async (non-blocking) or defer (delayed execution) attributes into scripts to skyrocket your Google PageSpeed scores.
    • Flexible Injection Methods: Print code Inline directly to the page, or as an Enqueued File to take advantage of browser caching.
    • Automatic Code Minification: Automatically strips comments and whitespace from your custom snippets to reduce payload size.
  • 3. One-Click Native Pixel Integrations:
    No more copying messy code blocks. Simply paste your tracking IDs for optimized, automated deployment of:

    • Google Tag Manager (GTM): Automated header script and body <noscript> fallback setup.
    • Google Analytics 4 (GA4): Cleanly enqueues the modern Global Site Tag (gtag.js).
    • Meta Facebook Pixel: Automated base header code and noscript image tag fallback.
  • 4. Complete Snippet Management System (CPT):
    Move beyond global boxes into an organized, custom post type management engine:

    • Unlimited Isolated Snippets: Create distinct, named snippets for individual marketing campaigns instead of mixing all code together.
    • Execution Priority Control: Assign execution weights (e.g., Priority 10 vs 50) to strictly command the exact order scripts print to the page.
    • Instant Status Toggles: Safely toggle individual snippets Active or Inactive with a single click without deleting your code.

Donations

If you enjoy this plugin and want to support development, you can buy me a coffee:
👉 https://www.buymeacoffee.com/mahethekiller

Support & Documentation

For support, feature requests, or documentation, please visit the official support forum on WordPress.org.

Privacy Policy

This plugin does not collect or share personal data. It only safely loads the scripts you explicitly provide. Any data processing relies entirely on the external scripts you choose to implement (e.g., Google Analytics, Facebook Pixel).

屏幕截图

  • Main Settings Page – Add scripts globally.
  • Code Editor – Syntax highlighting for easy editing.

安装

  1. Go to your WordPress Dashboard, navigate to Plugins Add New, and search for Header Footer Script Adder.
  2. Click Install Now and then Activate the plugin.
  3. Access the configuration dashboard by navigating to Settings Header Footer Script Adder in your admin menu.
  4. Paste your code snippets, configure your loading conditions, and click Save.

Manual Installation via ZIP

  1. Download the plugin .zip file from the WordPress repository.
  2. In your WordPress Admin, go to Plugins Add New Upload Plugin and select the zip file.
  3. Install, activate, and navigate to Settings Header Footer Script Adder to begin.

常见问题

Is this plugin safe to use?

Yes. All inputs are sanitized, and access is restricted strictly to administrators to prevent unauthorized script injections. It strictly adheres to WordPress core security standards.

Will it slow down my website performance?

Not at all. The plugin is intentionally lightweight and optimized. Scripts are only queried and executed on the specific pages you designate via conditional formatting.

Can I add scripts to a single page only?

Yes. You can use the per-page override settings directly within the post or page editor sidebar to inject exclusive scripts.

Does it support Gutenberg (Block Editor)?

Yes. It is fully compatible with both the modern Gutenberg Block Editor and the legacy Classic Editor interface.

Can I run this on a WordPress Multisite network?

Yes. The plugin is multisite ready, allowing each sub-site on your network to maintain its own independent script configuration.

Can I insert multiple scripts into the same section?

Yes. You can paste multiple independent scripts (e.g., Google Analytics and Facebook Pixel together) sequentially into the header, body, or footer areas.

Will my tracking codes disappear if I switch my theme?

No. All codes are securely written into the WordPress database, meaning you can swap, edit, or update themes without ever losing your tracking configurations.

How do I remove plugin data completely?

Upon uninstallation, the plugin provides a clean teardown option to wipe all saved script configurations completely from your database.

Will adding tracking pixels slow down my Core Web Vitals?

Third-party scripts are the #1 cause of poor mobile page speed. While the Free version prints scripts exactly as you paste them, the Pro version includes built-in optimization tools. You can apply “Async” or “Defer” tags to your scripts with a single click, or force them to load as enqueued files to maintain blazing-fast loading speeds and high Google PageSpeed scores.

How do I upgrade to the Pro version?

Upgrading is completely seamless. Once you are ready to unlock advanced targeting and optimization, navigate to the “Header Footer Script Adder” menu in your WordPress dashboard and click on the “Upgrade” or “Go Pro” tab to securely purchase and instantly activate your premium license via Freemius without losing any of your existing scripts.

评价

2025 年 10 月 24 日
I love this plugin. It allows you to add to <head> on per page basis, which not a lot of these script inserter type plugins do. I use this to preload LCP images on a per page basis, which helps improve your website’s core web vitals (better visitor experience, and improved rankings!). I had one issue, I messaged support, and got a reply AND A FIX in a very short space of time. I was impressed!If you need to do per page <head>, <body> or footer scripts on a per page basis, this plugin is a winner!
2025 年 6 月 19 日
I was looking for an easy way to add some custom JavaScript and tracking pixels to my WordPress site without digging into theme files—and this plugin did the job perfectly. The Header and Footer Script Adder is incredibly straightforward. Just copy your code, paste it into the header or footer box, and you’re good to go. It even lets you add scripts to individual pages or posts, which is super useful for things like conversion tracking. What I really like: Super lightweight – doesn’t slow down my site at all. No complicated setup – very beginner friendly. Works across themes – I switched themes recently, and all my scripts still worked without any issues. Honestly, it’s one of those plugins that does one thing and does it really well. No clutter, no unnecessary settings—just clean and effective. If you need to insert scripts without breaking your site or getting lost in code, give this plugin a try. It’s now one of my go-to tools for every WordPress project!
2025 年 6 月 19 日
I’ve been using the Header and Footer Script Adder plugin for a few weeks now, and it’s been a lifesaver. I needed a simple way to add custom scripts like Google Analytics, chat widgets, and a few tracking codes to my site—without touching theme files or editing functions.php. This plugin does exactly what it promises. You can easily insert code into the header or footer of your entire site or even just on specific posts or pages. The interface is super simple and straightforward. No bloated settings or confusing options. Just paste your code and save—done! What I love most is that it works regardless of the theme I’m using, so I don’t have to worry about losing my scripts if I change themes in the future. Would recommend this plugin to: Beginners who need a quick solution for adding scripts. Developers who want a clean, no-fuss way to insert site-wide or page-level code. Anyone who wants to keep things organized and avoid messing with core files. There are no unnecessary features, and that’s honestly a good thing. It keeps everything lightweight and easy to manage. Great job to the developer! This one’s staying on my must-have list.
2025 年 6 月 19 日
This plugin is very simple and easy to use, i have used it in many projects i does what it says. also new update is great.
2017 年 3 月 13 日 1 回复
This is the reason I’m getting more and more frustrated with WordPress. Can’t add a simple <script> element to my site, without having to paddle through 5 lousy plugins… This plugin does fulfil its simple role (that I wouldn’t even need if WordPress had built in some elementary HTML customisation), but somehow decided that it’s appropriate to spam me and other admins with requests for donations on every dashboard page that we open – and I couldn’t disable this without deleting the plugin. Look, I understand you want to make some cash, but then please clearly mark this as freemium or make it a paid thing. This thing you’re doing now is just plain rude.
阅读所有4条评价

贡献者及开发者

「Header Footer Script Adder – Insert Code in Header, Body & Footer」是开源软件。 以下人员对此插件做出了贡献。

贡献者

更新日志

2.0.7

  • Converted plugin architecture to a unified Single Version Model.
  • Integrated Freemius SDK for secure premium features delivery.
  • Added Pro Version upgrade dashboard and conditionally-loaded premium code structure.
  • Verified compatibility with latest WordPress version 6.7.

2.0.6

  • Fixed a few security issues.

2.0.5

  • Minor bug fixes and improvements.

2.0.3

  • Major release.
  • Added global header, body, and footer script support.
  • Conditional loading (sitewide, homepage, posts, archives).
  • Per-page script overrides.
  • Integrated CodeMirror editor.
  • Improved sanitization and security.
  • Block Editor and Classic Editor compatibility.
  • Performance optimizations.
  • Updated documentation.

1.2.0

  • Added new features and bug fixes.
  • Improved UI for easier code management.

1.0.0

  • Initial release.