Bonsai Code Injector
A minimal WordPress plugin for pasting tracking and verification code into a site's <head> and immediately after <body> — without editing theme files.
by The Bonsai Digital Collective · github.com/bonsai-systems/bonsai-code-injector · website
★ 0stars
0forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/bonsai-systems/bonsai-code-injector/archive/refs/heads/main.zipFrom the readme
Bonsai Code Injector
A minimal WordPress plugin for pasting tracking and verification code into a site's and immediately after — without editing theme files.
Features
- Settings page under Settings → Code Injector
- Header Code field — printed as early as possible inside on every front-end page (wphead, priority 1). Use for the GA4 gtag.js snippet, the Google Tag Manager block, or search-console-style meta verification tags.
- Body Code field — printed immediately after the opening tag via wpbodyopen. Use for the Google Tag Manager snippet.
- Access restricted to manageoptions by default (filterable via bonsaicodeinjectorcapability).
- Options removed on uninstall.
Requirements
- WordPress 6.0+
- PHP 8.0+
- Theme must call wpbodyopen() in header.php for the Body Code field to output. Bonsai base themes do this by default.
Usage
1. Activate the plugin.
2. Go to Settings → Code Injector.
3. Paste your GA4/GTM/other tracking snippets into the relevant field and save.
Google Tag Manager
- Paste the ... install snippet into Header Code.
- Paste the ... install snippet into Body Code.
GA4 (gtag.js, no GTM)
- Paste the full gtag.js snippet into Header Code. No Body Code e
Read the full README on GitHub →
Releases
These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.